Chromium Code Reviews| Index: runtime/platform/thread_win.cc |
| diff --git a/runtime/platform/thread_win.cc b/runtime/platform/thread_win.cc |
| index e3d76ea01643d58acdc66b03da4e7dd390fb9689..5fe99d61b5709cb1ee60f8511d3f1c841c5c54cd 100644 |
| --- a/runtime/platform/thread_win.cc |
| +++ b/runtime/platform/thread_win.cc |
| @@ -14,17 +14,16 @@ class ThreadStartData { |
| public: |
| ThreadStartData(Thread::ThreadStartFunction function, |
| uword parameter, |
| - Thread* thread) |
| - : function_(function), parameter_(parameter), thread_(thread) {} |
| + bool joinable) |
|
Ivan Posva
2012/01/24 02:04:01
joinable is a thing of the past.
Søren Gjesse
2012/01/24 12:07:55
Sorry, did not test this change on Windows.
|
| + : function_(function), parameter_(parameter), joinable_(joinable) {} |
| Thread::ThreadStartFunction function() const { return function_; } |
| uword parameter() const { return parameter_; } |
| - Thread* thread() const { return thread_; } |
| private: |
| Thread::ThreadStartFunction function_; |
| uword parameter_; |
| - Thread* thread_; |
| + bool joinable_; |
| DISALLOW_COPY_AND_ASSIGN(ThreadStartData); |
| }; |
| @@ -38,33 +37,27 @@ static unsigned int __stdcall ThreadEntry(void* data_ptr) { |
| Thread::ThreadStartFunction function = data->function(); |
| uword parameter = data->parameter(); |
| - Thread* thread = data->thread(); |
| delete data; |
| // Call the supplied thread start function handing it its parameters. |
| function(parameter); |
| - // When the function returns here, make sure that the thread is deleted. |
| - delete thread; |
| + // When the function returns here close the handle. |
| + CloseHandle(GetCurrentThread()); |
| return 0; |
| } |
| -Thread::Thread(ThreadStartFunction function, uword parameter) { |
| - ThreadStartData* start_data = new ThreadStartData(function, parameter, this); |
| +ThreadHandle Thread::Start(ThreadStartFunction function, uword parameter) { |
| + ThreadStartData* start_data = new ThreadStartData( |
| + function, parameter, (flags & kJoinable) != 0); |
| uint32_t tid; |
| - data_.thread_handle_ = |
| - _beginthreadex(NULL, 64 * KB, ThreadEntry, start_data, 0, &tid); |
| - if (data_.thread_handle_ == -1) { |
| + uintptr_t thread = |
| + _beginthreadex(NULL, 64 * KB, ThreadEntry, start_data, 0, &tid); |
| + if (thread == kInvalidThreadHandle) { |
| FATAL("Thread creation failed"); |
| } |
| - data_.tid_ = tid; |
| -} |
| - |
| - |
| -Thread::~Thread() { |
| - CloseHandle(reinterpret_cast<HANDLE>(data_.thread_handle_)); |
| } |