| Index: src/platform-macos.cc
|
| diff --git a/src/platform-macos.cc b/src/platform-macos.cc
|
| index bfdf3b21c0ff1ef38c3f663049626f9cfa6ef61b..3e10b6a1124bb0aedb937d8adc5dfe5ac21abf60 100644
|
| --- a/src/platform-macos.cc
|
| +++ b/src/platform-macos.cc
|
| @@ -392,50 +392,14 @@ bool VirtualMemory::Uncommit(void* address, size_t size) {
|
| }
|
|
|
|
|
| -class ThreadHandle::PlatformData : public Malloced {
|
| +class Thread::PlatformData : public Malloced {
|
| public:
|
| - explicit PlatformData(ThreadHandle::Kind kind) {
|
| - Initialize(kind);
|
| - }
|
| -
|
| - void Initialize(ThreadHandle::Kind kind) {
|
| - switch (kind) {
|
| - case ThreadHandle::SELF: thread_ = pthread_self(); break;
|
| - case ThreadHandle::INVALID: thread_ = kNoThread; break;
|
| - }
|
| - }
|
| + PlatformData() : thread_(kNoThread) {}
|
| pthread_t thread_; // Thread handle for pthread.
|
| };
|
|
|
| -
|
| -
|
| -ThreadHandle::ThreadHandle(Kind kind) {
|
| - data_ = new PlatformData(kind);
|
| -}
|
| -
|
| -
|
| -void ThreadHandle::Initialize(ThreadHandle::Kind kind) {
|
| - data_->Initialize(kind);
|
| -}
|
| -
|
| -
|
| -ThreadHandle::~ThreadHandle() {
|
| - delete data_;
|
| -}
|
| -
|
| -
|
| -bool ThreadHandle::IsSelf() const {
|
| - return pthread_equal(data_->thread_, pthread_self());
|
| -}
|
| -
|
| -
|
| -bool ThreadHandle::IsValid() const {
|
| - return data_->thread_ != kNoThread;
|
| -}
|
| -
|
| -
|
| Thread::Thread(Isolate* isolate, const Options& options)
|
| - : ThreadHandle(ThreadHandle::INVALID),
|
| + : data_(new PlatformData),
|
| isolate_(isolate),
|
| stack_size_(options.stack_size) {
|
| set_name(options.name);
|
| @@ -443,7 +407,7 @@ Thread::Thread(Isolate* isolate, const Options& options)
|
|
|
|
|
| Thread::Thread(Isolate* isolate, const char* name)
|
| - : ThreadHandle(ThreadHandle::INVALID),
|
| + : data_(new PlatformData),
|
| isolate_(isolate),
|
| stack_size_(0) {
|
| set_name(name);
|
| @@ -451,6 +415,7 @@ Thread::Thread(Isolate* isolate, const char* name)
|
|
|
|
|
| Thread::~Thread() {
|
| + delete data_;
|
| }
|
|
|
|
|
| @@ -476,9 +441,9 @@ static void* ThreadEntry(void* arg) {
|
| // This is also initialized by the first argument to pthread_create() but we
|
| // don't know which thread will run first (the original thread or the new
|
| // one) so we initialize it here too.
|
| - thread->thread_handle_data()->thread_ = pthread_self();
|
| + thread->data()->thread_ = pthread_self();
|
| SetThreadName(thread->name());
|
| - ASSERT(thread->IsValid());
|
| + ASSERT(thread->data()->thread_ != kNoThread);
|
| Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate());
|
| thread->Run();
|
| return NULL;
|
| @@ -499,13 +464,13 @@ void Thread::Start() {
|
| pthread_attr_setstacksize(&attr, static_cast<size_t>(stack_size_));
|
| attr_ptr = &attr;
|
| }
|
| - pthread_create(&thread_handle_data()->thread_, attr_ptr, ThreadEntry, this);
|
| - ASSERT(IsValid());
|
| + pthread_create(&data_->thread_, attr_ptr, ThreadEntry, this);
|
| + ASSERT(data_->thread_ != kNoThread);
|
| }
|
|
|
|
|
| void Thread::Join() {
|
| - pthread_join(thread_handle_data()->thread_, NULL);
|
| + pthread_join(data_->thread_, NULL);
|
| }
|
|
|
|
|
|
|