You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2014/11/16 02:39:02 UTC
[05/30] mesos git commit: Introduced a libev async watcher
specifically for updating timers.
Introduced a libev async watcher specifically for updating timers.
Review: https://reviews.apache.org/r/27502
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/18cc45f1
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/18cc45f1
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/18cc45f1
Branch: refs/heads/master
Commit: 18cc45f1f0c27e1766be9c1227c24d63c14bbcb0
Parents: e1ef91f
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sun Nov 2 16:49:22 2014 -0800
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Sat Nov 15 16:25:58 2014 -0800
----------------------------------------------------------------------
3rdparty/libprocess/src/process.cpp | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/18cc45f1/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index 2282e9b..a0b4ca0 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -449,9 +449,14 @@ static ProcessManager* process_manager = NULL;
// Event loop.
static struct ev_loop* loop = NULL;
-// Asynchronous watcher for interrupting loop.
+// Asynchronous watcher for interrupting loop to specifically deal
+// with IO watchers and functions (via run_in_event_loop).
static ev_async async_watcher;
+// Asynchronous watcher for interrupting loop to specifically deal
+// with updating timers.
+static ev_async async_update_timer_watcher;
+
// Watcher for timeouts.
static ev_timer timeouts_watcher;
@@ -609,7 +614,7 @@ void Clock::resume()
clock::settling = false;
clock::currents->clear();
update_timer = true;
- ev_async_send(loop, &async_watcher);
+ ev_async_send(loop, &async_update_timer_watcher);
}
}
}
@@ -624,7 +629,7 @@ void Clock::advance(const Duration& duration)
VLOG(2) << "Clock advanced (" << duration << ") to " << clock::current;
if (!update_timer) {
update_timer = true;
- ev_async_send(loop, &async_watcher);
+ ev_async_send(loop, &async_update_timer_watcher);
}
}
}
@@ -655,7 +660,7 @@ void Clock::update(const Time& time)
VLOG(2) << "Clock updated to " << clock::current;
if (!update_timer) {
update_timer = true;
- ev_async_send(loop, &async_watcher);
+ ev_async_send(loop, &async_update_timer_watcher);
}
}
}
@@ -866,7 +871,11 @@ void handle_async(struct ev_loop* loop, ev_async* _, int revents)
functions->pop();
}
}
+}
+
+void handle_async_update_timer(struct ev_loop* loop, ev_async* _, int revents)
+{
synchronized (timeouts) {
if (update_timer) {
if (!timeouts->empty()) {
@@ -1619,6 +1628,9 @@ void initialize(const string& delegate)
ev_async_init(&async_watcher, handle_async);
ev_async_start(loop, &async_watcher);
+ ev_async_init(&async_update_timer_watcher, handle_async_update_timer);
+ ev_async_start(loop, &async_update_timer_watcher);
+
ev_timer_init(&timeouts_watcher, handle_timeouts, 0., 2100000.0);
ev_timer_again(loop, &timeouts_watcher);
@@ -3226,7 +3238,7 @@ Timer Clock::timer(
// Need to interrupt the loop to update/set timer repeat.
(*timeouts)[timer.timeout().time()].push_back(timer);
update_timer = true;
- ev_async_send(loop, &async_watcher);
+ ev_async_send(loop, &async_update_timer_watcher);
} else {
// Timer repeat is adequate, just add the timeout.
CHECK(timeouts->size() >= 1);