| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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 "vm/os_thread.h" | 5 #include "vm/os_thread.h" |
| 6 | 6 |
| 7 #include "vm/atomic.h" | 7 #include "vm/atomic.h" |
| 8 #include "vm/lockers.h" | 8 #include "vm/lockers.h" |
| 9 #include "vm/log.h" | 9 #include "vm/log.h" |
| 10 #include "vm/thread_interrupter.h" | 10 #include "vm/thread_interrupter.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 timeline_block_(NULL), | 29 timeline_block_(NULL), |
| 30 thread_list_next_(NULL), | 30 thread_list_next_(NULL), |
| 31 thread_interrupt_disabled_(1), // Thread interrupts disabled by default. | 31 thread_interrupt_disabled_(1), // Thread interrupts disabled by default. |
| 32 log_(new class Log()), | 32 log_(new class Log()), |
| 33 stack_base_(0), | 33 stack_base_(0), |
| 34 thread_(NULL) { | 34 thread_(NULL) { |
| 35 } | 35 } |
| 36 | 36 |
| 37 | 37 |
| 38 OSThread* OSThread::CreateOSThread() { | 38 OSThread* OSThread::CreateOSThread() { |
| 39 ASSERT(thread_list_lock_ != NULL); | 39 if (thread_list_lock_ == NULL) { |
| 40 MutexLocker ml(thread_list_lock_); | |
| 41 if (!creation_enabled_) { | |
| 42 return NULL; | 40 return NULL; |
| 43 } | 41 } |
| 44 OSThread* os_thread = new OSThread(); | 42 { |
| 45 AddThreadToListLocked(os_thread); | 43 MutexLocker ml(thread_list_lock_); |
| 46 return os_thread; | 44 if (!creation_enabled_) { |
| 45 return NULL; |
| 46 } |
| 47 OSThread* os_thread = new OSThread(); |
| 48 AddThreadToListLocked(os_thread); |
| 49 return os_thread; |
| 50 } |
| 47 } | 51 } |
| 48 | 52 |
| 49 | 53 |
| 50 OSThread::~OSThread() { | 54 OSThread::~OSThread() { |
| 51 RemoveThreadFromList(this); | 55 RemoveThreadFromList(this); |
| 52 delete log_; | 56 delete log_; |
| 53 log_ = NULL; | 57 log_ = NULL; |
| 54 if (Timeline::recorder() != NULL) { | 58 if (Timeline::recorder() != NULL) { |
| 55 Timeline::recorder()->FinishBlock(timeline_block_); | 59 Timeline::recorder()->FinishBlock(timeline_block_); |
| 56 } | 60 } |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 268 |
| 265 OSThread* OSThreadIterator::Next() { | 269 OSThread* OSThreadIterator::Next() { |
| 266 ASSERT(OSThread::thread_list_lock_ != NULL); | 270 ASSERT(OSThread::thread_list_lock_ != NULL); |
| 267 ASSERT(OSThread::thread_list_lock_->IsOwnedByCurrentThread()); | 271 ASSERT(OSThread::thread_list_lock_->IsOwnedByCurrentThread()); |
| 268 OSThread* current = next_; | 272 OSThread* current = next_; |
| 269 next_ = next_->thread_list_next_; | 273 next_ = next_->thread_list_next_; |
| 270 return current; | 274 return current; |
| 271 } | 275 } |
| 272 | 276 |
| 273 } // namespace dart | 277 } // namespace dart |
| OLD | NEW |