Commit 00a0d0a5 authored by Dominik Charousset's avatar Dominik Charousset

Return whether `allow` consumed a message

parent 057b9aa2
...@@ -384,10 +384,7 @@ public: ...@@ -384,10 +384,7 @@ public:
allow_clause(allow_clause&& other) = default; allow_clause(allow_clause&& other) = default;
~allow_clause() { ~allow_clause() {
if (peek_ != nullptr) { eval();
if (peek_())
run_once();
}
} }
allow_clause& from(const wildcard&) { allow_clause& from(const wildcard&) {
...@@ -428,6 +425,16 @@ public: ...@@ -428,6 +425,16 @@ public:
}; };
} }
bool eval() {
if (peek_ != nullptr) {
if (peek_()) {
run_once();
return true;
}
}
return false;
}
protected: protected:
void run_once() { void run_once() {
auto dptr = dynamic_cast<caf::blocking_actor*>(dest_); auto dptr = dynamic_cast<caf::blocking_actor*>(dest_);
...@@ -609,10 +616,12 @@ struct test_coordinator_fixture { ...@@ -609,10 +616,12 @@ struct test_coordinator_fixture {
/// Convenience macro for defining allow clauses. /// Convenience macro for defining allow clauses.
#define allow(types, fields) \ #define allow(types, fields) \
do { \ ([&] { \
CAF_MESSAGE("allow" << #types << "." << #fields); \ CAF_MESSAGE("allow" << #types << "." << #fields); \
allow_clause<CAF_EXPAND(CAF_DSL_LIST types)>{sched}.fields; \ allow_clause<CAF_EXPAND(CAF_DSL_LIST types)> x{sched}; \
} while (false) x.fields; \
return x.eval(); \
})()
/// Convenience macro for defining disallow clauses. /// Convenience macro for defining disallow clauses.
#define disallow(types, fields) \ #define disallow(types, fields) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment