fixed dispatcher + minor changes

This commit is contained in:
Michele Caini
2018-04-13 13:56:10 +02:00
parent 338eb75bab
commit c9bf38ce36
2 changed files with 6 additions and 12 deletions

View File

@@ -47,14 +47,10 @@ class Dispatcher final {
using sink_type = typename SigH<void(const Event &)>::sink_type;
void publish() override {
for(const auto &event: events[current]) {
signal.publish(event);
}
events[current].clear();
++current;
const auto &curr = current++;
current %= std::extent<decltype(events)>::value;
std::for_each(events[curr].cbegin(), events[curr].cend(), [this](const auto &event) { signal.publish(event); });
events[curr].clear();
}
inline sink_type sink() noexcept {

View File

@@ -306,9 +306,9 @@ public:
* @param args Arguments to use to invoke listeners.
*/
void publish(Args... args) {
for(auto &&call: calls) {
std::for_each(calls.begin(), calls.end(), [&args...](auto &&call) {
call.second(call.first, args...);
}
});
}
/**
@@ -319,9 +319,7 @@ public:
collector_type collect(Args... args) {
collector_type collector;
for(auto pos = calls.size(); pos; --pos) {
auto &call = calls[pos-1];
for(auto &&call: calls) {
if(!this->invoke(collector, call.second, call.first, args...)) {
break;
}