Commit e617c101 authored by hpayer@chromium.org's avatar hpayer@chromium.org

Make thread_creation_mutex a Thread::PlatformData member.

BUG=
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/198643003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19933 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 62054826
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment