| Index: src/platform-linux.cc
|
| diff --git a/src/platform-linux.cc b/src/platform-linux.cc
|
| index 73a6ccbdf887920d6c70dcd0b2ba11c8dcb2a45f..402a4b037c5c829b2d63197de524a36a37f537af 100644
|
| --- a/src/platform-linux.cc
|
| +++ b/src/platform-linux.cc
|
| @@ -588,50 +588,15 @@ 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);
|
| @@ -639,7 +604,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);
|
| @@ -647,6 +612,7 @@ Thread::Thread(Isolate* isolate, const char* name)
|
|
|
|
|
| Thread::~Thread() {
|
| + delete data_;
|
| }
|
|
|
|
|
| @@ -658,8 +624,8 @@ static void* ThreadEntry(void* arg) {
|
| prctl(PR_SET_NAME,
|
| reinterpret_cast<unsigned long>(thread->name()), // NOLINT
|
| 0, 0, 0);
|
| - thread->thread_handle_data()->thread_ = pthread_self();
|
| - ASSERT(thread->IsValid());
|
| + thread->data()->thread_ = pthread_self();
|
| + ASSERT(thread->data()->thread_ != kNoThread);
|
| Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate());
|
| thread->Run();
|
| return NULL;
|
| @@ -680,13 +646,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);
|
| }
|
|
|
|
|
|
|