aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-06-12 19:28:47 -0400
committerDeterminant <[email protected]>2019-06-12 19:28:47 -0400
commit2fe09084fa633d30cabe2595fd4c4b088971d47c (patch)
treef9282471f0b3b911808e0723a338105ac055ab18 /include
parente27e529e589ef89fbe010ebf7c5635ec2873f64f (diff)
deduplicate the error callback
Diffstat (limited to 'include')
-rw-r--r--include/salticidae/conn.h3
-rw-r--r--include/salticidae/event.h19
2 files changed, 8 insertions, 14 deletions
diff --git a/include/salticidae/conn.h b/include/salticidae/conn.h
index 42e87aa..6fc1288 100644
--- a/include/salticidae/conn.h
+++ b/include/salticidae/conn.h
@@ -254,6 +254,7 @@ class ConnPool {
void set_dispatcher() { disp_flag = true; }
bool is_dispatcher() const { return disp_flag; }
size_t get_nconn() { return nconn; }
+ void stop_tcall() { tcall.stop(); }
};
/* related to workers */
@@ -361,6 +362,8 @@ class ConnPool {
on_fatal_error(err);
}
});
+ disp_ec.stop();
+ workers[0].stop_tcall();
};
worker_error_cb = [this](const std::exception_ptr err) {
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; }
};
}