You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by dm...@apache.org on 2015/02/11 21:11:11 UTC
mesos git commit: Remove more non-pod statics from clock
Repository: mesos
Updated Branches:
refs/heads/master d8ae6c863 -> 95c448f77
Remove more non-pod statics from clock
Review: https://reviews.apache.org/r/30886
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/95c448f7
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/95c448f7
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/95c448f7
Branch: refs/heads/master
Commit: 95c448f77731034114183fc5f5bf6e040d4c0f5d
Parents: d8ae6c8
Author: Dominic Hamon <dh...@twitter.com>
Authored: Wed Feb 11 11:54:31 2015 -0800
Committer: Dominic Hamon <dh...@twitter.com>
Committed: Wed Feb 11 12:10:30 2015 -0800
----------------------------------------------------------------------
3rdparty/libprocess/src/clock.cpp | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/95c448f7/3rdparty/libprocess/src/clock.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/clock.cpp b/3rdparty/libprocess/src/clock.cpp
index f3fe6dc..b92d5de 100644
--- a/3rdparty/libprocess/src/clock.cpp
+++ b/3rdparty/libprocess/src/clock.cpp
@@ -38,12 +38,10 @@ namespace clock {
map<ProcessBase*, Time>* currents = new map<ProcessBase*, Time>();
-// TODO(dhamon): These static non-POD instances should be replaced by pointers
-// or functions.
-Time initial = Time::epoch();
-Time current = Time::epoch();
+Time* initial = new Time(Time::epoch());
+Time* current = new Time(Time::epoch());
-Duration advanced = Duration::zero();
+Duration* advanced = new Duration(Duration::zero());
bool paused = false;
@@ -135,7 +133,7 @@ void tick()
synchronized (timers) {
if (clock::paused &&
(timers->size() == 0 ||
- timers->begin()->first > clock::current)) {
+ timers->begin()->first > *clock::current)) {
VLOG(3) << "Clock has settled";
clock::settling = false;
}
@@ -163,10 +161,10 @@ Time Clock::now(ProcessBase* process)
if (clock::currents->count(process) != 0) {
return (*clock::currents)[process];
} else {
- return (*clock::currents)[process] = clock::initial;
+ return (*clock::currents)[process] = *clock::initial;
}
} else {
- return clock::current;
+ return *clock::current;
}
}
}
@@ -251,7 +249,7 @@ void Clock::pause()
synchronized (timers) {
if (!clock::paused) {
- clock::initial = clock::current = now();
+ *clock::initial = *clock::current = now();
clock::paused = true;
VLOG(2) << "Clock paused at " << clock::initial;
}
@@ -295,8 +293,8 @@ void Clock::advance(const Duration& duration)
{
synchronized (timers) {
if (clock::paused) {
- clock::advanced += duration;
- clock::current += duration;
+ *clock::advanced += duration;
+ *clock::current += duration;
VLOG(2) << "Clock advanced (" << duration << ") to " << clock::current;
@@ -328,9 +326,9 @@ void Clock::update(const Time& time)
{
synchronized (timers) {
if (clock::paused) {
- if (clock::current < time) {
- clock::advanced += (time - clock::current);
- clock::current = Time(time);
+ if (*clock::current < time) {
+ *clock::advanced += (time - *clock::current);
+ *clock::current = Time(time);
VLOG(2) << "Clock updated to " << clock::current;
// Schedule another "tick" if necessary.
@@ -373,7 +371,7 @@ bool Clock::settled()
VLOG(3) << "Clock still not settled";
return false;
} else if (timers->size() == 0 ||
- timers->begin()->first > clock::current) {
+ timers->begin()->first > *clock::current) {
VLOG(3) << "Clock is settled";
return true;
}
@@ -393,7 +391,7 @@ Try<Time> Time::create(double seconds)
Try<Duration> duration = Duration::create(seconds);
if (duration.isSome()) {
// In production code, clock::advanced will always be zero!
- return Time(duration.get() + clock::advanced);
+ return Time(duration.get() + *clock::advanced);
} else {
return Error("Argument too large for Time: " + duration.error());
}