Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Unified Diff: mojo/public/utility/lib/run_loop.cc

Issue 148013006: Mojo: re-org public/utility and public/environment (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: lower similarity factor Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/tests/utility/thread_local_unittest.cc ('k') | mojo/public/utility/lib/thread_local.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/utility/lib/run_loop.cc
diff --git a/mojo/public/utility/run_loop.cc b/mojo/public/utility/lib/run_loop.cc
similarity index 93%
rename from mojo/public/utility/run_loop.cc
rename to mojo/public/utility/lib/run_loop.cc
index bec828d6a77d146cb25375a2976b58ff6638dee9..78de63f30713072db9c89074a62d169afb268753 100644
--- a/mojo/public/utility/run_loop.cc
+++ b/mojo/public/utility/lib/run_loop.cc
@@ -9,13 +9,13 @@
#include <algorithm>
#include <vector>
+#include "mojo/public/utility/lib/thread_local.h"
#include "mojo/public/utility/run_loop_handler.h"
-#include "mojo/public/utility/thread_local.h"
namespace mojo {
namespace {
-ThreadLocalPointer<RunLoop>* tls_run_loop = NULL;
+internal::ThreadLocalPointer<RunLoop> current_run_loop;
const MojoTimeTicks kInvalidTimeTicks = static_cast<MojoTimeTicks>(0);
@@ -37,34 +37,29 @@ struct RunLoop::RunState {
};
RunLoop::RunLoop() : run_state_(NULL), next_handler_id_(0) {
- assert(tls_run_loop);
- assert(!tls_run_loop->Get());
- tls_run_loop->Set(this);
+ assert(!current());
+ current_run_loop.Set(this);
}
RunLoop::~RunLoop() {
- assert(tls_run_loop->Get() == this);
- tls_run_loop->Set(NULL);
+ assert(current() == this);
+ current_run_loop.Set(NULL);
}
// static
void RunLoop::SetUp() {
- assert(!tls_run_loop);
- tls_run_loop = new ThreadLocalPointer<RunLoop>;
+ current_run_loop.Allocate();
}
// static
void RunLoop::TearDown() {
assert(!current());
- assert(tls_run_loop);
- delete tls_run_loop;
- tls_run_loop = NULL;
+ current_run_loop.Free();
}
// static
RunLoop* RunLoop::current() {
- assert(tls_run_loop);
- return tls_run_loop->Get();
+ return current_run_loop.Get();
}
void RunLoop::AddHandler(RunLoopHandler* handler,
« no previous file with comments | « mojo/public/tests/utility/thread_local_unittest.cc ('k') | mojo/public/utility/lib/thread_local.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698