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

Unified Diff: src/platform-posix.cc

Issue 198643003: Make thread_creation_mutex a Thread::PlatformData member. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-posix.cc
diff --git a/src/platform-posix.cc b/src/platform-posix.cc
index 0ec458905892e9488e45ee2e58df059bf60a841c..439140ac0adc3563a04ccb068114c7071c91c99b 100644
--- a/src/platform-posix.cc
+++ b/src/platform-posix.cc
@@ -565,6 +565,8 @@ class Thread::PlatformData : public Malloced {
public:
PlatformData() : thread_(kNoThread) {}
pthread_t thread_; // Thread handle for pthread.
+ // Synchronizes thread creation
+ Mutex thread_creation_mutex_;
};
Thread::Thread(const Options& options)
@@ -583,10 +585,6 @@ Thread::~Thread() {
}
-// Synchronizes thread creation
-static Mutex thread_creation_mutex_;
-
-
static void SetThreadName(const char* name) {
#if V8_OS_DRAGONFLYBSD || V8_OS_FREEBSD || V8_OS_OPENBSD
pthread_set_name_np(pthread_self(), name);
@@ -619,7 +617,7 @@ static void* ThreadEntry(void* arg) {
// We take the lock here to make sure that pthread_create finished first since
// we don't know which thread will run first (the original thread or the new
// one).
- { LockGuard<Mutex> lock_guard(&thread_creation_mutex_); }
+ { LockGuard<Mutex> lock_guard(&thread->data()->thread_creation_mutex_); }
SetThreadName(thread->name());
ASSERT(thread->data()->thread_ != kNoThread);
thread->NotifyStartedAndRun();
@@ -647,7 +645,7 @@ void Thread::Start() {
}
#endif
{
- LockGuard<Mutex> lock_guard(&thread_creation_mutex_);
+ LockGuard<Mutex> lock_guard(&data_->thread_creation_mutex_);
result = pthread_create(&data_->thread_, &attr, ThreadEntry, this);
}
ASSERT_EQ(0, result);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698