Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Unified Diff: runtime/platform/thread_linux.cc

Issue 9141005: Change the thread interface in runtime/platform and use it starting all threads (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed Thread::Join as suggested by iposva@ Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/platform/thread_linux.cc
diff --git a/runtime/platform/thread_linux.cc b/runtime/platform/thread_linux.cc
index 338c4c8d1cab8cf9ebb01ae465117f5e20c6b779..eb22cac423e7f1ea6a32988fc82ec9e365a74b0d 100644
--- a/runtime/platform/thread_linux.cc
+++ b/runtime/platform/thread_linux.cc
@@ -35,18 +35,15 @@ 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) {}
+ uword parameter)
+ : function_(function), parameter_(parameter) {}
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);
};
@@ -60,20 +57,16 @@ static void* ThreadStart(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;
-
return NULL;
}
-Thread::Thread(ThreadStartFunction function, uword parameter) {
+void Thread::Start(ThreadStartFunction function, uword parameter) {
pthread_attr_t attr;
int result = pthread_attr_init(&attr);
VALIDATE_PTHREAD_RESULT(result);
@@ -84,26 +77,17 @@ Thread::Thread(ThreadStartFunction function, uword parameter) {
result = pthread_attr_setstacksize(&attr, 1024 * KB);
VALIDATE_PTHREAD_RESULT(result);
- ThreadStartData* data = new ThreadStartData(function, parameter, this);
+ ThreadStartData* data = new ThreadStartData(function, parameter);
pthread_t tid;
- result = pthread_create(&tid,
- &attr,
- ThreadStart,
- data);
+ 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);

Powered by Google App Engine
This is Rietveld 408576698