Index: runtime/platform/thread_macos.cc |
diff --git a/runtime/vm/thread_macos.cc b/runtime/platform/thread_macos.cc |
similarity index 68% |
copy from runtime/vm/thread_macos.cc |
copy to runtime/platform/thread_macos.cc |
index 4137df45d53523fec89c7babe7e0afb92107408e..cacfcd88a04913c1eaef447c0a634c69adcdde1c 100644 |
--- a/runtime/vm/thread_macos.cc |
+++ b/runtime/platform/thread_macos.cc |
@@ -5,7 +5,7 @@ |
#include <sys/errno.h> |
#include "platform/assert.h" |
-#include "vm/thread.h" |
+#include "platform/thread.h" |
namespace dart { |
@@ -15,78 +15,6 @@ namespace dart { |
} |
-class ThreadStartData { |
- public: |
- ThreadStartData(Thread::ThreadStartFunction function, |
- uword parameter, |
- Thread* thread) |
- : function_(function), parameter_(parameter), thread_(thread) {} |
- |
- Thread::ThreadStartFunction function() const { return function_; } |
- uword parameter() const { return parameter_; } |
- Thread* thread() const { return thread_; } |
- |
- private: |
- Thread::ThreadStartFunction function_; |
- uword parameter_; |
- Thread* thread_; |
- |
- DISALLOW_COPY_AND_ASSIGN(ThreadStartData); |
-}; |
- |
- |
-// Dispatch to the thread start function provided by the caller. This trampoline |
-// is used to ensure that the thread is properly destroyed if the thread just |
-// exits. |
-static void* ThreadStart(void* data_ptr) { |
- ThreadStartData* data = reinterpret_cast<ThreadStartData*>(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; |
- |
- return NULL; |
-} |
- |
- |
-Thread::Thread(ThreadStartFunction function, uword parameter) { |
- pthread_attr_t attr; |
- int result = pthread_attr_init(&attr); |
- VALIDATE_PTHREAD_RESULT(result); |
- |
- result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
- VALIDATE_PTHREAD_RESULT(result); |
- |
- result = pthread_attr_setstacksize(&attr, 64 * KB); |
- VALIDATE_PTHREAD_RESULT(result); |
- |
- ThreadStartData* data = new ThreadStartData(function, parameter, this); |
- |
- pthread_t tid; |
- result = pthread_create(&tid, |
- &attr, |
- ThreadStart, |
- data); |
- VALIDATE_PTHREAD_RESULT(result); |
- |
- data_.tid_ = tid; |
- |
- result = pthread_attr_destroy(&attr); |
- VALIDATE_PTHREAD_RESULT(result); |
-} |
- |
- |
-Thread::~Thread() { |
-} |
- |
- |
Mutex::Mutex() { |
pthread_mutexattr_t attr; |
int result = pthread_mutexattr_init(&attr); |