| Index: src/platform-cygwin.cc
|
| diff --git a/src/platform-cygwin.cc b/src/platform-cygwin.cc
|
| index d591b9dc27162e5432dc29d6a59f260769aaf7d5..65113282be38788799aa173c2003bb4a968d781b 100644
|
| --- a/src/platform-cygwin.cc
|
| +++ b/src/platform-cygwin.cc
|
| @@ -362,50 +362,17 @@ 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);
|
| @@ -413,7 +380,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);
|
| @@ -421,6 +388,7 @@ Thread::Thread(Isolate* isolate, const char* name)
|
|
|
|
|
| Thread::~Thread() {
|
| + delete data_;
|
| }
|
|
|
|
|
| @@ -429,8 +397,8 @@ 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();
|
| - ASSERT(thread->IsValid());
|
| + thread->data()->thread_ = pthread_self();
|
| + ASSERT(thread->data()->thread_ != kNoThread);
|
| Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate());
|
| thread->Run();
|
| return NULL;
|
| @@ -451,13 +419,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);
|
| }
|
|
|
|
|
|
|