aboutsummaryrefslogtreecommitdiff
path: root/include/salticidae/event.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/salticidae/event.h')
-rw-r--r--include/salticidae/event.h19
1 files changed, 5 insertions, 14 deletions
diff --git a/include/salticidae/event.h b/include/salticidae/event.h
index 5a315dd..eb0b382 100644
--- a/include/salticidae/event.h
+++ b/include/salticidae/event.h
@@ -467,14 +467,8 @@ class MPSCQueueEventDriven: public MPSCQueue<T> {
// since all enqueue operations are finalized, the dequeue should be able
// to see those enqueued values in func()
wait_sig.exchange(true, std::memory_order_acq_rel);
- bool again;
- try {
- again = func(*this);
- } catch (SalticidaeError &err) {
+ if (func(*this))
write(fd, &dummy, 8);
- throw err;
- }
- if (again) write(fd, &dummy, 8);
});
ev.add(FdEvent::READ);
}
@@ -558,6 +552,7 @@ class ThreadCall {
const size_t burst_size;
using queue_t = MPSCQueueEventDriven<Handle *>;
queue_t q;
+ bool stopped;
public:
struct Result {
@@ -607,7 +602,7 @@ class ThreadCall {
}
};
- ThreadCall(size_t burst_size): burst_size(burst_size) {}
+ ThreadCall(size_t burst_size): burst_size(burst_size), stopped(false) {}
ThreadCall(const ThreadCall &) = delete;
ThreadCall(ThreadCall &&) = delete;
ThreadCall(EventContext ec, size_t burst_size = 128): ec(ec), burst_size(burst_size) {
@@ -616,12 +611,7 @@ class ThreadCall {
Handle *h;
while (q.try_dequeue(h))
{
- try {
- h->exec();
- } catch (SalticidaeError &err) {
- delete h;
- throw err;
- }
+ if (!stopped) h->exec();
delete h;
if (++cnt == burst_size) return true;
}
@@ -652,6 +642,7 @@ class ThreadCall {
}
const EventContext &get_ec() const { return ec; }
+ void stop() { stopped = true; }
};
}