From e27e529e589ef89fbe010ebf7c5635ec2873f64f Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 12 Jun 2019 19:14:40 -0400 Subject: WIP: error handling --- include/salticidae/event.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'include/salticidae/event.h') diff --git a/include/salticidae/event.h b/include/salticidae/event.h index 91637e4..5a315dd 100644 --- a/include/salticidae/event.h +++ b/include/salticidae/event.h @@ -467,8 +467,14 @@ class MPSCQueueEventDriven: public MPSCQueue { // 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); - if (func(*this)) + bool again; + try { + again = func(*this); + } catch (SalticidaeError &err) { write(fd, &dummy, 8); + throw err; + } + if (again) write(fd, &dummy, 8); }); ev.add(FdEvent::READ); } @@ -610,7 +616,12 @@ class ThreadCall { Handle *h; while (q.try_dequeue(h)) { - h->exec(); + try { + h->exec(); + } catch (SalticidaeError &err) { + delete h; + throw err; + } delete h; if (++cnt == burst_size) return true; } -- cgit v1.2.3