Commit 709b793f authored by Dominik Charousset's avatar Dominik Charousset

Fix behavior of `trigger(x, 0)`

parent 4500d0ad
...@@ -122,13 +122,18 @@ public: ...@@ -122,13 +122,18 @@ public:
/// Allows `num_events` activities on `hdl`. /// Allows `num_events` activities on `hdl`.
template <class Handle> template <class Handle>
void trigger(Handle hdl, size_t num_events) { void trigger(Handle hdl, size_t num_events) {
if (num_events > 0) { auto ref = by_id(hdl);
auto ref = by_id(hdl); if (!ref)
if (ref)
ref->trigger(num_events);
return; return;
if (num_events > 0) {
ref->trigger(num_events);
} else {
// if we have any number of activity tokens, ignore this call
// otherwise (currently in unconditional receive state) halt
auto x = ref->activity_tokens();
if (!x)
ref->halt();
} }
halt(hdl);
} }
/// Modifies the receive policy for given connection. /// Modifies the receive policy for given connection.
......
...@@ -65,6 +65,10 @@ public: ...@@ -65,6 +65,10 @@ public:
this->add_to_loop(); this->add_to_loop();
} }
inline optional<size_t> activity_tokens() const {
return activity_tokens_;
}
protected: protected:
void detach_from(abstract_broker* ptr) override { void detach_from(abstract_broker* ptr) override {
ptr->erase(hdl_); ptr->erase(hdl_);
......
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