| Index: runtime/platform/thread_linux.cc
|
| diff --git a/runtime/vm/thread_linux.cc b/runtime/platform/thread_linux.cc
|
| similarity index 71%
|
| copy from runtime/vm/thread_linux.cc
|
| copy to runtime/platform/thread_linux.cc
|
| index a46ec80139b7bb4d1b46b3427196ca6df71acf45..0e2bda1bca38493da748a3a09f00a2caea20f066 100644
|
| --- a/runtime/vm/thread_linux.cc
|
| +++ b/runtime/platform/thread_linux.cc
|
| @@ -31,78 +31,6 @@ static void ComputeTimeSpec(struct timespec* ts, int64_t millis) {
|
| }
|
|
|
|
|
| -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, 1024 * 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);
|
|
|