From b84497791d19d90793c758c7d8e88e57c9d142e6 Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 16 Nov 2018 15:50:22 -0500 Subject: WIP: stress test; fix bugs --- include/salticidae/event.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'include/salticidae/event.h') diff --git a/include/salticidae/event.h b/include/salticidae/event.h index 3fd11b6..2cda44f 100644 --- a/include/salticidae/event.h +++ b/include/salticidae/event.h @@ -125,7 +125,7 @@ class Event { ev_fd(other.ev_fd), ev_timer(other.ev_timer), callback(std::move(other.callback)) { other.del(); - if (fd != -1) + if (ev_fd != nullptr) { other.ev_fd = nullptr; ev_fd->data = this; @@ -143,7 +143,7 @@ class Event { ev_timer = other.ev_timer; callback = std::move(other.callback); - if (fd != -1) + if (ev_fd != nullptr) { other.ev_fd = nullptr; ev_fd->data = this; @@ -181,7 +181,7 @@ class Event { void del() { if (ev_fd) uv_poll_stop(ev_fd); if (ev_timer == nullptr) - assert(ev_timer); + assert(ev_timer); uv_timer_stop(ev_timer); } void add_with_timeout(double t_sec, int events) { @@ -205,11 +205,9 @@ class ThreadNotifier { return data; } void notify(void *_data) { - { - mutex_lg_t _(mlock); - ready = true; - data = _data; - } + mutex_lg_t _(mlock); + ready = true; + data = _data; cv.notify_all(); } }; -- cgit v1.2.3