Repository: mesos
Updated Branches:
  refs/heads/master 4209ad61c -> a8130d3c2


Refactored libprocess class ProcessReference into its own header.

Move class ProcessReference out of process.cpp and into its own header.
Part of refactoring process.cpp.

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


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

Branch: refs/heads/master
Commit: a8130d3c2c14c758043eeede2f189cab6245b1f6
Parents: 4209ad6
Author: Joris Van Remoortere <[email protected]>
Authored: Thu Sep 25 13:18:25 2014 -0700
Committer: Niklas Q. Nielsen <[email protected]>
Committed: Thu Sep 25 13:18:25 2014 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/Makefile.am               |  1 +
 3rdparty/libprocess/src/process.cpp           | 76 +-------------------
 3rdparty/libprocess/src/process_reference.hpp | 84 ++++++++++++++++++++++
 3 files changed, 86 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a8130d3c/3rdparty/libprocess/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/Makefile.am b/3rdparty/libprocess/Makefile.am
index 36773d9..616618e 100644
--- a/3rdparty/libprocess/Makefile.am
+++ b/3rdparty/libprocess/Makefile.am
@@ -40,6 +40,7 @@ libprocess_la_SOURCES =               \
   src/metrics/metrics.cpp      \
   src/pid.cpp                  \
   src/process.cpp              \
+  src/process_reference.hpp    \
   src/reap.cpp                 \
   src/subprocess.cpp           \
   src/synchronized.hpp         \

http://git-wip-us.apache.org/repos/asf/mesos/blob/a8130d3c/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp 
b/3rdparty/libprocess/src/process.cpp
index 8adc809..e46e6b1 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -82,6 +82,7 @@
 #include "decoder.hpp"
 #include "encoder.hpp"
 #include "gate.hpp"
+#include "process_reference.hpp"
 #include "synchronized.hpp"
 
 using namespace process::metrics::internal;
@@ -138,81 +139,6 @@ map<string, string> types;
 } // namespace mime {
 
 
-// Provides reference counting semantics for a process pointer.
-class ProcessReference
-{
-public:
-  ProcessReference() : process(NULL) {}
-
-  ~ProcessReference()
-  {
-    cleanup();
-  }
-
-  ProcessReference(const ProcessReference& that)
-  {
-    copy(that);
-  }
-
-  ProcessReference& operator = (const ProcessReference& that)
-  {
-    if (this != &that) {
-      cleanup();
-      copy(that);
-    }
-    return *this;
-  }
-
-  ProcessBase* operator -> ()
-  {
-    return process;
-  }
-
-  operator ProcessBase* ()
-  {
-    return process;
-  }
-
-  operator bool () const
-  {
-    return process != NULL;
-  }
-
-private:
-  friend class ProcessManager; // For ProcessManager::use.
-
-  explicit ProcessReference(ProcessBase* _process)
-    : process(_process)
-  {
-    if (process != NULL) {
-      __sync_fetch_and_add(&(process->refs), 1);
-    }
-  }
-
-  void copy(const ProcessReference& that)
-  {
-    process = that.process;
-
-    if (process != NULL) {
-      // There should be at least one reference to the process, so
-      // we don't need to worry about checking if it's exiting or
-      // not, since we know we can always create another reference.
-      CHECK(process->refs > 0);
-      __sync_fetch_and_add(&(process->refs), 1);
-    }
-  }
-
-  void cleanup()
-  {
-    if (process != NULL) {
-      __sync_fetch_and_sub(&(process->refs), 1);
-    }
-  }
-
-  ProcessBase* process;
-};
-
-
 // Provides a process that manages sending HTTP responses so as to
 // satisfy HTTP/1.1 pipelining. Each request should either enqueue a
 // response, or ask the proxy to handle a future response. The process

http://git-wip-us.apache.org/repos/asf/mesos/blob/a8130d3c/3rdparty/libprocess/src/process_reference.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process_reference.hpp 
b/3rdparty/libprocess/src/process_reference.hpp
new file mode 100644
index 0000000..4964107
--- /dev/null
+++ b/3rdparty/libprocess/src/process_reference.hpp
@@ -0,0 +1,84 @@
+#ifndef PROCESS_REFERENCE_HPP
+#define PROCESS_REFERENCE_HPP
+
+#include <process/process.hpp>
+
+namespace process {
+
+// Provides reference counting semantics for a process pointer.
+class ProcessReference
+{
+public:
+  ProcessReference() : process(NULL) {}
+
+  ~ProcessReference()
+  {
+    cleanup();
+  }
+
+  ProcessReference(const ProcessReference& that)
+  {
+    copy(that);
+  }
+
+  ProcessReference& operator = (const ProcessReference& that)
+  {
+    if (this != &that) {
+      cleanup();
+      copy(that);
+    }
+    return *this;
+  }
+
+  ProcessBase* operator -> ()
+  {
+    return process;
+  }
+
+  operator ProcessBase* ()
+  {
+    return process;
+  }
+
+  operator bool () const
+  {
+    return process != NULL;
+  }
+
+private:
+  friend class ProcessManager; // For ProcessManager::use.
+
+  explicit ProcessReference(ProcessBase* _process)
+    : process(_process)
+  {
+    if (process != NULL) {
+      __sync_fetch_and_add(&(process->refs), 1);
+    }
+  }
+
+  void copy(const ProcessReference& that)
+  {
+    process = that.process;
+
+    if (process != NULL) {
+      // There should be at least one reference to the process, so
+      // we don't need to worry about checking if it's exiting or
+      // not, since we know we can always create another reference.
+      CHECK(process->refs > 0);
+      __sync_fetch_and_add(&(process->refs), 1);
+    }
+  }
+
+  void cleanup()
+  {
+    if (process != NULL) {
+      __sync_fetch_and_sub(&(process->refs), 1);
+    }
+  }
+
+  ProcessBase* process;
+};
+
+} // namespace process {
+
+#endif // PROCESS_REFERENCE_HPP

Reply via email to