| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file | 
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a | 
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "platform/thread.h" | 5 #include "platform/thread.h" | 
| 6 | 6 | 
| 7 #include <errno.h> | 7 #include <errno.h> | 
| 8 #include <sys/time.h> | 8 #include <sys/time.h> | 
| 9 | 9 | 
| 10 #include "platform/assert.h" | 10 #include "platform/assert.h" | 
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 96   result = pthread_create(&tid, &attr, ThreadStart, data); | 96   result = pthread_create(&tid, &attr, ThreadStart, data); | 
| 97   RETURN_ON_PTHREAD_FAILURE(result); | 97   RETURN_ON_PTHREAD_FAILURE(result); | 
| 98 | 98 | 
| 99   result = pthread_attr_destroy(&attr); | 99   result = pthread_attr_destroy(&attr); | 
| 100   RETURN_ON_PTHREAD_FAILURE(result); | 100   RETURN_ON_PTHREAD_FAILURE(result); | 
| 101 | 101 | 
| 102   return 0; | 102   return 0; | 
| 103 } | 103 } | 
| 104 | 104 | 
| 105 | 105 | 
|  | 106 ThreadLocalKey Thread::kUnsetThreadLocalKey = static_cast<pthread_key_t>(-1); | 
|  | 107 | 
|  | 108 | 
|  | 109 ThreadLocalKey Thread::CreateThreadLocal() { | 
|  | 110   pthread_key_t key = kUnsetThreadLocalKey; | 
|  | 111   int result = pthread_key_create(&key, NULL); | 
|  | 112   VALIDATE_PTHREAD_RESULT(result); | 
|  | 113   ASSERT(key != kUnsetThreadLocalKey); | 
|  | 114   return key; | 
|  | 115 } | 
|  | 116 | 
|  | 117 | 
|  | 118 void Thread::DeleteThreadLocal(ThreadLocalKey key) { | 
|  | 119   ASSERT(key != kUnsetThreadLocalKey); | 
|  | 120   int result = pthread_key_delete(key); | 
|  | 121   VALIDATE_PTHREAD_RESULT(result); | 
|  | 122 } | 
|  | 123 | 
|  | 124 | 
|  | 125 void Thread::SetThreadLocal(ThreadLocalKey key, uword value) { | 
|  | 126   ASSERT(key != kUnsetThreadLocalKey); | 
|  | 127   int result = pthread_setspecific(key, reinterpret_cast<void*>(value)); | 
|  | 128   VALIDATE_PTHREAD_RESULT(result); | 
|  | 129 } | 
|  | 130 | 
|  | 131 | 
| 106 Mutex::Mutex() { | 132 Mutex::Mutex() { | 
| 107   pthread_mutexattr_t attr; | 133   pthread_mutexattr_t attr; | 
| 108   int result = pthread_mutexattr_init(&attr); | 134   int result = pthread_mutexattr_init(&attr); | 
| 109   VALIDATE_PTHREAD_RESULT(result); | 135   VALIDATE_PTHREAD_RESULT(result); | 
| 110 | 136 | 
| 111 #if defined(DEBUG) | 137 #if defined(DEBUG) | 
| 112   result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); | 138   result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); | 
| 113   VALIDATE_PTHREAD_RESULT(result); | 139   VALIDATE_PTHREAD_RESULT(result); | 
| 114 #endif  // defined(DEBUG) | 140 #endif  // defined(DEBUG) | 
| 115 | 141 | 
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 240 } | 266 } | 
| 241 | 267 | 
| 242 | 268 | 
| 243 void Monitor::NotifyAll() { | 269 void Monitor::NotifyAll() { | 
| 244   // TODO(iposva): Do we need to track lock owners? | 270   // TODO(iposva): Do we need to track lock owners? | 
| 245   int result = pthread_cond_broadcast(data_.cond()); | 271   int result = pthread_cond_broadcast(data_.cond()); | 
| 246   VALIDATE_PTHREAD_RESULT(result); | 272   VALIDATE_PTHREAD_RESULT(result); | 
| 247 } | 273 } | 
| 248 | 274 | 
| 249 }  // namespace dart | 275 }  // namespace dart | 
| OLD | NEW | 
|---|