Index: runtime/vm/os_thread_win.cc |
diff --git a/runtime/vm/os_thread_win.cc b/runtime/vm/os_thread_win.cc |
index 3802a1633900b8e0df5205cc0eecff6e4a314f24..9d282bc2f8132d8046338fc320c7e9bba701b9a5 100644 |
--- a/runtime/vm/os_thread_win.cc |
+++ b/runtime/vm/os_thread_win.cc |
@@ -6,6 +6,7 @@ |
#if defined(TARGET_OS_WINDOWS) |
#include "vm/growable_array.h" |
+#include "vm/lockers.h" |
#include "vm/os_thread.h" |
#include <process.h> // NOLINT |
@@ -565,7 +566,7 @@ void ThreadLocalData::AddThreadLocal(ThreadLocalKey key, |
// We only care about thread locals with destructors. |
return; |
} |
- mutex_->Lock(); |
+ MutexLocker ml(mutex_, false); |
#if defined(DEBUG) |
// Verify that we aren't added twice. |
for (intptr_t i = 0; i < thread_locals_->length(); i++) { |
@@ -575,12 +576,12 @@ void ThreadLocalData::AddThreadLocal(ThreadLocalKey key, |
#endif |
// Add to list. |
thread_locals_->Add(ThreadLocalEntry(key, destructor)); |
- mutex_->Unlock(); |
} |
void ThreadLocalData::RemoveThreadLocal(ThreadLocalKey key) { |
- ASSERT(thread_locals_ != NULL); mutex_->Lock(); |
+ ASSERT(thread_locals_ != NULL); |
+ MutexLocker ml(mutex_, false); |
intptr_t i = 0; |
for (; i < thread_locals_->length(); i++) { |
const ThreadLocalEntry& entry = thread_locals_->At(i); |
@@ -590,11 +591,9 @@ void ThreadLocalData::RemoveThreadLocal(ThreadLocalKey key) { |
} |
if (i == thread_locals_->length()) { |
// Not found. |
- mutex_->Unlock(); |
return; |
} |
thread_locals_->RemoveAt(i); |
- mutex_->Unlock(); |
} |
@@ -603,7 +602,7 @@ void ThreadLocalData::RemoveThreadLocal(ThreadLocalKey key) { |
void ThreadLocalData::RunDestructors() { |
ASSERT(thread_locals_ != NULL); |
ASSERT(mutex_ != NULL); |
- mutex_->Lock(); |
+ MutexLocker ml(mutex_, false); |
for (intptr_t i = 0; i < thread_locals_->length(); i++) { |
const ThreadLocalEntry& entry = thread_locals_->At(i); |
// We access the exiting thread's TLS variable here. |
@@ -611,7 +610,6 @@ void ThreadLocalData::RunDestructors() { |
// We invoke the constructor here. |
entry.destructor()(p); |
} |
- mutex_->Unlock(); |
} |