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:03 UTC

[06/30] mesos git commit: Simplified redundant Clock::order/update usage.

Simplified redundant Clock::order/update usage.

Review: https://reviews.apache.org/r/27501


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e1ef91fb
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e1ef91fb
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e1ef91fb

Branch: refs/heads/master
Commit: e1ef91fb0c711d6bf69e72e468a2c2c55684e07f
Parents: 6df6d02
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sun Nov 2 16:18:57 2014 -0800
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Sat Nov 15 16:25:58 2014 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/clock.hpp | 16 ++++++-
 3rdparty/libprocess/src/process.cpp           | 51 +++++-----------------
 2 files changed, 25 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e1ef91fb/3rdparty/libprocess/include/process/clock.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/clock.hpp b/3rdparty/libprocess/include/process/clock.hpp
index ae7d0fb..db0fb04 100644
--- a/3rdparty/libprocess/include/process/clock.hpp
+++ b/3rdparty/libprocess/include/process/clock.hpp
@@ -45,7 +45,21 @@ public:
   static void advance(ProcessBase* process, const Duration& duration);
 
   static void update(const Time& time);
-  static void update(ProcessBase* process, const Time& time);
+
+  // When updating the time of a particular process you can specify
+  // whether or not you want to override the existing value even if
+  // you're going backwards in time! SAFE means don't update the
+  // previous Clock for a process if going backwards in time, where as
+  // FORCE forces this change.
+  enum Update {
+    SAFE,
+    FORCE,
+  };
+
+  static void update(
+      ProcessBase* process,
+      const Time& time,
+      Update update = SAFE);
 
   static void order(ProcessBase* from, ProcessBase* to);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/e1ef91fb/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index 0995a9c..2282e9b 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -663,11 +663,11 @@ void Clock::update(const Time& time)
 }
 
 
-void Clock::update(ProcessBase* process, const Time& time)
+void Clock::update(ProcessBase* process, const Time& time, Update update)
 {
   synchronized (timeouts) {
     if (clock::paused) {
-      if (now(process) < time) {
+      if (now(process) < time || update == Clock::FORCE) {
         VLOG(2) << "Clock of " << process->self() << " updated to " << time;
         (*clock::currents)[process] = Time(time);
       }
@@ -2644,15 +2644,7 @@ bool ProcessManager::deliver(
   // the duration of this routine (so that we can look up it's current
   // time).
   if (Clock::paused()) {
-    synchronized (timeouts) {
-      if (Clock::paused()) {
-        if (sender != NULL) {
-          Clock::order(sender, receiver);
-        } else {
-          Clock::update(receiver, Clock::now());
-        }
-      }
-    }
+    Clock::update(receiver, Clock::now(sender != NULL ? sender : __process__));
   }
 
   receiver->enqueue(event);
@@ -2948,15 +2940,7 @@ void ProcessManager::terminate(
 {
   if (ProcessReference process = use(pid)) {
     if (Clock::paused()) {
-      synchronized (timeouts) {
-        if (Clock::paused()) {
-          if (sender != NULL) {
-            Clock::order(sender, process);
-          } else {
-            Clock::update(process, Clock::now());
-          }
-        }
-      }
+      Clock::update(process, Clock::now(sender != NULL ? sender : __process__));
     }
 
     if (sender != NULL) {
@@ -3293,18 +3277,10 @@ ProcessBase::ProcessBase(const string& id)
   pid.node = __node__;
 
   // If using a manual clock, try and set current time of process
-  // using happens before relationship between creator and createe!
+  // using happens before relationship between creator (__process__)
+  // and createe (this)!
   if (Clock::paused()) {
-    synchronized (timeouts) {
-      if (Clock::paused()) {
-        clock::currents->erase(this); // In case the address is reused!
-        if (__process__ != NULL) {
-          Clock::order(__process__, this);
-        } else {
-          Clock::update(this, Clock::now());
-        }
-      }
-    }
+    Clock::update(this, Clock::now(__process__), Clock::FORCE);
   }
 }
 
@@ -3512,17 +3488,10 @@ UPID spawn(ProcessBase* process, bool manage)
 
   if (process != NULL) {
     // If using a manual clock, try and set current time of process
-    // using happens before relationship between spawner and spawnee!
+    // using happens before relationship between spawner (__process__)
+    // and spawnee (process)!
     if (Clock::paused()) {
-      synchronized (timeouts) {
-        if (Clock::paused()) {
-          if (__process__ != NULL) {
-            Clock::order(__process__, process);
-          } else {
-            Clock::update(process, Clock::now());
-          }
-        }
-      }
+      Clock::update(process, Clock::now(__process__));
     }
 
     return process_manager->spawn(process, manage);