| 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 <sys/errno.h> |    7 #include <sys/errno.h> | 
|    8  |    8  | 
|    9 #include "platform/assert.h" |    9 #include "platform/assert.h" | 
|   10  |   10  | 
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   80   result = pthread_create(&tid, &attr, ThreadStart, data); |   80   result = pthread_create(&tid, &attr, ThreadStart, data); | 
|   81   RETURN_ON_PTHREAD_FAILURE(result); |   81   RETURN_ON_PTHREAD_FAILURE(result); | 
|   82  |   82  | 
|   83   result = pthread_attr_destroy(&attr); |   83   result = pthread_attr_destroy(&attr); | 
|   84   RETURN_ON_PTHREAD_FAILURE(result); |   84   RETURN_ON_PTHREAD_FAILURE(result); | 
|   85  |   85  | 
|   86   return 0; |   86   return 0; | 
|   87 } |   87 } | 
|   88  |   88  | 
|   89  |   89  | 
 |   90 ThreadLocalKey Thread::kUnsetThreadLocalKey = static_cast<pthread_key_t>(-1); | 
 |   91  | 
 |   92  | 
 |   93 ThreadLocalKey Thread::CreateThreadLocal() { | 
 |   94   pthread_key_t key = kUnsetThreadLocalKey; | 
 |   95   int result = pthread_key_create(&key, NULL); | 
 |   96   VALIDATE_PTHREAD_RESULT(result); | 
 |   97   ASSERT(key != kUnsetThreadLocalKey); | 
 |   98   return key; | 
 |   99 } | 
 |  100  | 
 |  101  | 
 |  102 void Thread::DeleteThreadLocal(ThreadLocalKey key) { | 
 |  103   ASSERT(key != kUnsetThreadLocalKey); | 
 |  104   int result = pthread_key_delete(key); | 
 |  105   VALIDATE_PTHREAD_RESULT(result); | 
 |  106 } | 
 |  107  | 
 |  108  | 
 |  109 void Thread::SetThreadLocal(ThreadLocalKey key, uword value) { | 
 |  110   ASSERT(key != kUnsetThreadLocalKey); | 
 |  111   int result = pthread_setspecific(key, reinterpret_cast<void*>(value)); | 
 |  112   VALIDATE_PTHREAD_RESULT(result); | 
 |  113 } | 
 |  114  | 
 |  115  | 
|   90 Mutex::Mutex() { |  116 Mutex::Mutex() { | 
|   91   pthread_mutexattr_t attr; |  117   pthread_mutexattr_t attr; | 
|   92   int result = pthread_mutexattr_init(&attr); |  118   int result = pthread_mutexattr_init(&attr); | 
|   93   VALIDATE_PTHREAD_RESULT(result); |  119   VALIDATE_PTHREAD_RESULT(result); | 
|   94  |  120  | 
|   95 #if defined(DEBUG) |  121 #if defined(DEBUG) | 
|   96   result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); |  122   result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); | 
|   97   VALIDATE_PTHREAD_RESULT(result); |  123   VALIDATE_PTHREAD_RESULT(result); | 
|   98 #endif  // defined(DEBUG) |  124 #endif  // defined(DEBUG) | 
|   99  |  125  | 
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  219 } |  245 } | 
|  220  |  246  | 
|  221  |  247  | 
|  222 void Monitor::NotifyAll() { |  248 void Monitor::NotifyAll() { | 
|  223   // TODO(iposva): Do we need to track lock owners? |  249   // TODO(iposva): Do we need to track lock owners? | 
|  224   int result = pthread_cond_broadcast(data_.cond()); |  250   int result = pthread_cond_broadcast(data_.cond()); | 
|  225   VALIDATE_PTHREAD_RESULT(result); |  251   VALIDATE_PTHREAD_RESULT(result); | 
|  226 } |  252 } | 
|  227  |  253  | 
|  228 }  // namespace dart |  254 }  // namespace dart | 
| OLD | NEW |