Repository: mesos
Updated Branches:
  refs/heads/master 963513722 -> c4db2df33


Revert "Replaced ThreadLocal use with thread_local."

This reverts commit f24db46b92796efaa15766c625b8ef4706240f2f.


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

Branch: refs/heads/master
Commit: c4db2df33a92a5f842ce6faac3cc1dfbbc057277
Parents: 9654512
Author: Benjamin Hindman <[email protected]>
Authored: Fri Jul 24 16:40:24 2015 -0700
Committer: Benjamin Hindman <[email protected]>
Committed: Fri Jul 24 16:40:33 2015 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/3rdparty/Makefile.am         |  1 +
 3rdparty/libprocess/include/process/executor.hpp | 12 ++++++++----
 3rdparty/libprocess/include/process/process.hpp  |  9 +++++++--
 3rdparty/libprocess/src/libev.cpp                |  2 +-
 3rdparty/libprocess/src/libev.hpp                | 13 ++++++++-----
 3rdparty/libprocess/src/libevent.cpp             |  2 +-
 3rdparty/libprocess/src/libevent.hpp             | 13 ++++++++-----
 3rdparty/libprocess/src/process.cpp              |  5 +++--
 8 files changed, 37 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c4db2df3/3rdparty/libprocess/3rdparty/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/Makefile.am 
b/3rdparty/libprocess/3rdparty/Makefile.am
index 790bb46..bd95fe1 100644
--- a/3rdparty/libprocess/3rdparty/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/Makefile.am
@@ -190,6 +190,7 @@ stout_tests_SOURCES =                               \
   $(STOUT)/tests/some_tests.cpp                        \
   $(STOUT)/tests/strings_tests.cpp             \
   $(STOUT)/tests/subcommand_tests.cpp          \
+  $(STOUT)/tests/thread_tests.cpp              \
   $(STOUT)/tests/uuid_tests.cpp                        \
   $(STOUT)/tests/version_tests.cpp
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/c4db2df3/3rdparty/libprocess/include/process/executor.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/executor.hpp 
b/3rdparty/libprocess/include/process/executor.hpp
index 3167f0b..434d23a 100644
--- a/3rdparty/libprocess/include/process/executor.hpp
+++ b/3rdparty/libprocess/include/process/executor.hpp
@@ -20,6 +20,8 @@
 #include <process/id.hpp>
 #include <process/process.hpp>
 
+#include <stout/thread.hpp>
+
 namespace process {
 
 // Provides an abstraction that can take a standard function object
@@ -66,12 +68,14 @@ private:
 };
 
 
-// Per thread executor pointer. We use a pointer to lazily construct the
-// actual executor.
-extern thread_local Executor* _executor_;
+// Per thread executor pointer. The extra level of indirection from
+// _executor_ to __executor__ is used in order to take advantage of
+// the ThreadLocal operators without needing the extra dereference as
+// well as lazily construct the actual executor.
+extern ThreadLocal<Executor>* _executor_;
 
 #define __executor__                                                    \
-  (_executor_ == NULL ? _executor_ = new Executor() : _executor_)
+  (*_executor_ == NULL ? *_executor_ = new Executor() : *_executor_)
 
 } // namespace process {
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/c4db2df3/3rdparty/libprocess/include/process/process.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/process.hpp 
b/3rdparty/libprocess/include/process/process.hpp
index 8908bd2..8620547 100644
--- a/3rdparty/libprocess/include/process/process.hpp
+++ b/3rdparty/libprocess/include/process/process.hpp
@@ -36,6 +36,7 @@
 #include <stout/lambda.hpp>
 #include <stout/option.hpp>
 #include <stout/synchronized.hpp>
+#include <stout/thread.hpp>
 
 namespace process {
 
@@ -504,8 +505,12 @@ inline bool wait(const ProcessBase* process, const 
Duration& duration)
 }
 
 
-// Per thread process pointer.
-extern thread_local ProcessBase* __process__;
+// Per thread process pointer. The extra level of indirection from
+// _process_ to __process__ is used in order to take advantage of the
+// ThreadLocal operators without needing the extra dereference.
+extern ThreadLocal<ProcessBase>* _process_;
+
+#define __process__ (*_process_)
 
 // NOTE: Methods in this namespace should only be used in tests to
 // inject arbitrary events.

http://git-wip-us.apache.org/repos/asf/mesos/blob/c4db2df3/3rdparty/libprocess/src/libev.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/libev.cpp 
b/3rdparty/libprocess/src/libev.cpp
index 5301ce0..55ed6ef 100644
--- a/3rdparty/libprocess/src/libev.cpp
+++ b/3rdparty/libprocess/src/libev.cpp
@@ -39,7 +39,7 @@ std::mutex* watchers_mutex = new std::mutex();
 std::queue<lambda::function<void(void)>>* functions =
   new std::queue<lambda::function<void(void)>>();
 
-thread_local bool* _in_event_loop_ = NULL;
+ThreadLocal<bool>* _in_event_loop_ = new ThreadLocal<bool>();
 
 
 void handle_async(struct ev_loop* loop, ev_async* _, int revents)

http://git-wip-us.apache.org/repos/asf/mesos/blob/c4db2df3/3rdparty/libprocess/src/libev.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/libev.hpp 
b/3rdparty/libprocess/src/libev.hpp
index fd8970b..fd26728 100644
--- a/3rdparty/libprocess/src/libev.hpp
+++ b/3rdparty/libprocess/src/libev.hpp
@@ -25,6 +25,7 @@
 
 #include <stout/lambda.hpp>
 #include <stout/synchronized.hpp>
+#include <stout/thread.hpp>
 
 namespace process {
 
@@ -46,12 +47,14 @@ extern std::mutex* watchers_mutex;
 // loop (protected by 'watchers' above).
 extern std::queue<lambda::function<void(void)>>* functions;
 
-// Per thread bool pointer. We use a pointer to lazily construct the
-// actual bool.
-extern thread_local bool* _in_event_loop_;
+// Per thread bool pointer. The extra level of indirection from
+// _in_event_loop_ to __in_event_loop__ is used in order to take
+// advantage of the ThreadLocal operators without needing the extra
+// dereference as well as lazily construct the actual bool.
+extern ThreadLocal<bool>* _in_event_loop_;
 
-#define __in_event_loop__ *(_in_event_loop_ == NULL ?                \
-  _in_event_loop_ = new bool(false) : _in_event_loop_)
+#define __in_event_loop__ *(*_in_event_loop_ == NULL ?               \
+  *_in_event_loop_ = new bool(false) : *_in_event_loop_)
 
 
 // Wrapper around function we want to run in the event loop.

http://git-wip-us.apache.org/repos/asf/mesos/blob/c4db2df3/3rdparty/libprocess/src/libevent.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/libevent.cpp 
b/3rdparty/libprocess/src/libevent.cpp
index 6e37946..1f175a4 100644
--- a/3rdparty/libprocess/src/libevent.cpp
+++ b/3rdparty/libprocess/src/libevent.cpp
@@ -38,7 +38,7 @@ std::queue<lambda::function<void(void)>>* functions =
   new std::queue<lambda::function<void(void)>>();
 
 
-thread_local bool* _in_event_loop_ = NULL;
+ThreadLocal<bool>* _in_event_loop_ = new ThreadLocal<bool>();
 
 
 void async_function(int socket, short which, void* arg)

http://git-wip-us.apache.org/repos/asf/mesos/blob/c4db2df3/3rdparty/libprocess/src/libevent.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/libevent.hpp 
b/3rdparty/libprocess/src/libevent.hpp
index 07acb14..3a0a46b 100644
--- a/3rdparty/libprocess/src/libevent.hpp
+++ b/3rdparty/libprocess/src/libevent.hpp
@@ -18,6 +18,7 @@
 #include <event2/event.h>
 
 #include <stout/lambda.hpp>
+#include <stout/thread.hpp>
 
 namespace process {
 
@@ -25,13 +26,15 @@ namespace process {
 extern event_base* base;
 
 
-// Per thread bool pointer. We use a pointer to lazily construct the
-// actual bool.
-extern thread_local bool* _in_event_loop_;
+// Per thread bool pointer. The extra level of indirection from
+// _in_event_loop_ to __in_event_loop__ is used in order to take
+// advantage of the ThreadLocal operators without needing the extra
+// dereference as well as lazily construct the actual bool.
+extern ThreadLocal<bool>* _in_event_loop_;
 
 
-#define __in_event_loop__ *(_in_event_loop_ == NULL ?                \
-  _in_event_loop_ = new bool(false) : _in_event_loop_)
+#define __in_event_loop__ *(*_in_event_loop_ == NULL ?               \
+  *_in_event_loop_ = new bool(false) : *_in_event_loop_)
 
 
 enum EventLoopLogicFlow {

http://git-wip-us.apache.org/repos/asf/mesos/blob/c4db2df3/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp 
b/3rdparty/libprocess/src/process.cpp
index 34bfe40..6d3609d 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -91,6 +91,7 @@
 #include <stout/path.hpp>
 #include <stout/strings.hpp>
 #include <stout/synchronized.hpp>
+#include <stout/thread.hpp>
 #include <stout/unreachable.hpp>
 
 #include "config.hpp"
@@ -466,10 +467,10 @@ PID<GarbageCollector> gc;
 PID<Help> help;
 
 // Per thread process pointer.
-thread_local ProcessBase* __process__ = NULL;
+ThreadLocal<ProcessBase>* _process_ = new ThreadLocal<ProcessBase>();
 
 // Per thread executor pointer.
-thread_local Executor* _executor_ = NULL;
+ThreadLocal<Executor>* _executor_ = new ThreadLocal<Executor>();
 
 // TODO(dhamon): Reintroduce this when it is plumbed through to Statistics.
 // const Duration LIBPROCESS_STATISTICS_WINDOW = Days(1);

Reply via email to