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:00 UTC
[03/30] mesos git commit: Replaced Timer::create/cancel with
Clock::timer/cancel.
Replaced Timer::create/cancel with Clock::timer/cancel.
Review: https://reviews.apache.org/r/27496
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/303ee1c3
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/303ee1c3
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/303ee1c3
Branch: refs/heads/master
Commit: 303ee1c3f23c0bb2cc6cfd58982848ea225ad2df
Parents: acd656c
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sat Nov 1 16:00:53 2014 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Sat Nov 15 16:25:57 2014 -0800
----------------------------------------------------------------------
3rdparty/libprocess/include/process/c++11/delay.hpp | 5 +++--
3rdparty/libprocess/include/process/clock.hpp | 16 +++++++++++++++-
3rdparty/libprocess/include/process/delay.hpp | 5 +++--
3rdparty/libprocess/include/process/future.hpp | 5 +++--
3rdparty/libprocess/include/process/timer.hpp | 11 ++++-------
3rdparty/libprocess/src/process.cpp | 4 ++--
6 files changed, 30 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/303ee1c3/3rdparty/libprocess/include/process/c++11/delay.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/c++11/delay.hpp b/3rdparty/libprocess/include/process/c++11/delay.hpp
index 5f686db..5818e83 100644
--- a/3rdparty/libprocess/include/process/c++11/delay.hpp
+++ b/3rdparty/libprocess/include/process/c++11/delay.hpp
@@ -1,6 +1,7 @@
#ifndef __PROCESS_DELAY_HPP__
#define __PROCESS_DELAY_HPP__
+#include <process/clock.hpp>
#include <process/dispatch.hpp>
#include <process/timer.hpp>
@@ -19,7 +20,7 @@ Timer delay(const Duration& duration,
const PID<T>& pid,
void (T::*method)())
{
- return Timer::create(duration, [=] () {
+ return Clock::timer(duration, [=] () {
dispatch(pid, method);
});
}
@@ -52,7 +53,7 @@ Timer delay(const Duration& duration,
void (T::*method)(ENUM_PARAMS(N, P)), \
ENUM_BINARY_PARAMS(N, A, a)) \
{ \
- return Timer::create(duration, [=] () { \
+ return Clock::timer(duration, [=] () { \
dispatch(pid, method, ENUM_PARAMS(N, a)); \
}); \
} \
http://git-wip-us.apache.org/repos/asf/mesos/blob/303ee1c3/3rdparty/libprocess/include/process/clock.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/clock.hpp b/3rdparty/libprocess/include/process/clock.hpp
index eb157ca..80190ef 100644
--- a/3rdparty/libprocess/include/process/clock.hpp
+++ b/3rdparty/libprocess/include/process/clock.hpp
@@ -2,27 +2,41 @@
#define __PROCESS_CLOCK_HPP__
#include <process/time.hpp>
+#include <process/timer.hpp>
#include <stout/duration.hpp>
+#include <stout/lambda.hpp>
namespace process {
-// Forward declarations.
+// Forward declarations (to avoid circular dependencies).
class ProcessBase;
class Time;
+class Timer;
class Clock
{
public:
static Time now();
static Time now(ProcessBase* process);
+
+ static Timer timer(
+ const Duration& duration,
+ const lambda::function<void(void)>& thunk);
+
+ static bool cancel(const Timer& timer);
+
static void pause();
static bool paused();
+
static void resume();
+
static void advance(const Duration& duration);
static void advance(ProcessBase* process, const Duration& duration);
+
static void update(const Time& time);
static void update(ProcessBase* process, const Time& time);
+
static void order(ProcessBase* from, ProcessBase* to);
// When the clock is paused, settle() synchronously ensures that:
http://git-wip-us.apache.org/repos/asf/mesos/blob/303ee1c3/3rdparty/libprocess/include/process/delay.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/delay.hpp b/3rdparty/libprocess/include/process/delay.hpp
index 487f652..40627ea 100644
--- a/3rdparty/libprocess/include/process/delay.hpp
+++ b/3rdparty/libprocess/include/process/delay.hpp
@@ -4,6 +4,7 @@
#ifndef __PROCESS_DELAY_HPP__
#define __PROCESS_DELAY_HPP__
+#include <process/clock.hpp>
#include <process/dispatch.hpp>
#include <process/timer.hpp>
@@ -40,7 +41,7 @@ Timer delay(const Duration& duration,
dispatcher,
internal::canonicalize(method));
- return Timer::create(duration, dispatch);
+ return Clock::timer(duration, dispatch);
}
@@ -87,7 +88,7 @@ Timer delay(const Duration& duration,
dispatcher, \
internal::canonicalize(method)); \
\
- return Timer::create(duration, dispatch); \
+ return Clock::timer(duration, dispatch); \
} \
\
template <typename T, \
http://git-wip-us.apache.org/repos/asf/mesos/blob/303ee1c3/3rdparty/libprocess/include/process/future.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/future.hpp b/3rdparty/libprocess/include/process/future.hpp
index 3ac1812..68e5f7b 100644
--- a/3rdparty/libprocess/include/process/future.hpp
+++ b/3rdparty/libprocess/include/process/future.hpp
@@ -18,6 +18,7 @@
#include <boost/type_traits.hpp>
#endif // __cplusplus < 201103L
+#include <process/clock.hpp>
#include <process/internal.hpp>
#include <process/latch.hpp>
#include <process/owned.hpp>
@@ -1491,7 +1492,7 @@ void after(
{
CHECK(!future.isPending());
if (latch->trigger()) {
- Timer::cancel(timer);
+ Clock::cancel(timer);
promise->associate(future);
}
}
@@ -1554,7 +1555,7 @@ Future<T> Future<T>::after(
// completed. Note that we do not pass a weak reference for this
// future as we don't want the future to get cleaned up and then
// have the timer expire.
- Timer timer = Timer::create(
+ Timer timer = Clock::timer(
duration,
lambda::bind(&internal::expired<T>, f, latch, promise, *this));
http://git-wip-us.apache.org/repos/asf/mesos/blob/303ee1c3/3rdparty/libprocess/include/process/timer.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/timer.hpp b/3rdparty/libprocess/include/process/timer.hpp
index e2f5563..e5d71f6 100644
--- a/3rdparty/libprocess/include/process/timer.hpp
+++ b/3rdparty/libprocess/include/process/timer.hpp
@@ -11,19 +11,14 @@
namespace process {
-// Timer support!
+// Timer represents a delayed thunk, that can get created (scheduled)
+// and canceled using the Clock.
class Timer
{
public:
Timer() : id(0), pid(process::UPID()), thunk(&abort) {}
- static Timer create(
- const Duration& duration,
- const lambda::function<void(void)>& thunk);
-
- static bool cancel(const Timer& timer);
-
bool operator == (const Timer& that) const
{
return id == that.id;
@@ -50,6 +45,8 @@ public:
}
private:
+ friend class Clock;
+
Timer(long _id,
const Timeout& _t,
const process::UPID& _pid,
http://git-wip-us.apache.org/repos/asf/mesos/blob/303ee1c3/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index 5842705..9ebac08 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -3160,7 +3160,7 @@ Future<Response> ProcessManager::__processes__(const Request&)
}
-Timer Timer::create(
+Timer Clock::timer(
const Duration& duration,
const lambda::function<void(void)>& thunk)
{
@@ -3194,7 +3194,7 @@ Timer Timer::create(
}
-bool Timer::cancel(const Timer& timer)
+bool Clock::cancel(const Timer& timer)
{
bool canceled = false;
synchronized (timeouts) {