OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 #include "vm/thread.h" |
| 6 |
| 7 #include "vm/isolate.h" |
| 8 #include "vm/os_thread.h" |
| 9 |
| 10 |
| 11 namespace dart { |
| 12 |
| 13 // The single thread local key which stores all the thread local data |
| 14 // for a thread. |
| 15 // TODO(koda): Can we merge this with ThreadInterrupter::thread_state_key_? |
| 16 ThreadLocalKey Thread::thread_key = OSThread::kUnsetThreadLocalKey; |
| 17 |
| 18 |
| 19 void Thread::InitOnce() { |
| 20 ASSERT(thread_key == OSThread::kUnsetThreadLocalKey); |
| 21 thread_key = OSThread::CreateThreadLocal(); |
| 22 ASSERT(thread_key != OSThread::kUnsetThreadLocalKey); |
| 23 } |
| 24 |
| 25 |
| 26 void Thread::SetCurrent(Thread* current) { |
| 27 OSThread::SetThreadLocal(thread_key, reinterpret_cast<uword>(current)); |
| 28 } |
| 29 |
| 30 } // namespace dart |
OLD | NEW |