Index: runtime/bin/thread_win.cc |
diff --git a/runtime/bin/thread_win.cc b/runtime/bin/thread_win.cc |
index 94d144a21a526ab23db0611a83ff358f44508744..38e6729d9390da4966f460b0e3ee2a172be073b1 100644 |
--- a/runtime/bin/thread_win.cc |
+++ b/runtime/bin/thread_win.cc |
@@ -30,7 +30,6 @@ class ThreadStartData { |
DISALLOW_COPY_AND_ASSIGN(ThreadStartData); |
}; |
- |
// Dispatch to the thread start function provided by the caller. This trampoline |
// is used to ensure that the thread is properly destroyed if the thread just |
// exits. |
@@ -52,7 +51,6 @@ static unsigned int __stdcall ThreadEntry(void* data_ptr) { |
return 0; |
} |
- |
int Thread::Start(ThreadStartFunction function, uword parameter) { |
ThreadStartData* start_data = new ThreadStartData(function, parameter); |
uint32_t tid; |
@@ -82,7 +80,6 @@ ThreadLocalKey Thread::CreateThreadLocal() { |
return key; |
} |
- |
void Thread::DeleteThreadLocal(ThreadLocalKey key) { |
ASSERT(key != kUnsetThreadLocalKey); |
BOOL result = TlsFree(key); |
@@ -91,29 +88,24 @@ void Thread::DeleteThreadLocal(ThreadLocalKey key) { |
} |
} |
- |
intptr_t Thread::GetMaxStackSize() { |
const int kStackSize = (128 * kWordSize * KB); |
return kStackSize; |
} |
- |
ThreadId Thread::GetCurrentThreadId() { |
return ::GetCurrentThreadId(); |
} |
- |
intptr_t Thread::ThreadIdToIntPtr(ThreadId id) { |
ASSERT(sizeof(id) <= sizeof(intptr_t)); |
return static_cast<intptr_t>(id); |
} |
- |
bool Thread::Compare(ThreadId a, ThreadId b) { |
return (a == b); |
} |
- |
void Thread::SetThreadLocal(ThreadLocalKey key, uword value) { |
ASSERT(key != kUnsetThreadLocalKey); |
BOOL result = TlsSetValue(key, reinterpret_cast<void*>(value)); |
@@ -122,13 +114,11 @@ void Thread::SetThreadLocal(ThreadLocalKey key, uword value) { |
} |
} |
- |
void Thread::InitOnce() { |
MonitorWaitData::monitor_wait_data_key_ = Thread::CreateThreadLocal(); |
MonitorData::GetMonitorWaitDataForThread(); |
} |
- |
Mutex::Mutex() { |
// Allocate unnamed semaphore with initial count 1 and max count 1. |
data_.semaphore_ = CreateSemaphore(NULL, 1, 1, NULL); |
@@ -137,12 +127,10 @@ Mutex::Mutex() { |
} |
} |
- |
Mutex::~Mutex() { |
CloseHandle(data_.semaphore_); |
} |
- |
void Mutex::Lock() { |
DWORD result = WaitForSingleObject(data_.semaphore_, INFINITE); |
if (result != WAIT_OBJECT_0) { |
@@ -150,7 +138,6 @@ void Mutex::Lock() { |
} |
} |
- |
bool Mutex::TryLock() { |
// Attempt to pass the semaphore but return immediately. |
DWORD result = WaitForSingleObject(data_.semaphore_, 0); |
@@ -164,7 +151,6 @@ bool Mutex::TryLock() { |
return false; |
} |
- |
void Mutex::Unlock() { |
BOOL result = ReleaseSemaphore(data_.semaphore_, 1, NULL); |
if (result == 0) { |
@@ -172,11 +158,9 @@ void Mutex::Unlock() { |
} |
} |
- |
ThreadLocalKey MonitorWaitData::monitor_wait_data_key_ = |
Thread::kUnsetThreadLocalKey; |
- |
Monitor::Monitor() { |
InitializeCriticalSection(&data_.cs_); |
InitializeCriticalSection(&data_.waiters_cs_); |
@@ -184,23 +168,19 @@ Monitor::Monitor() { |
data_.waiters_tail_ = NULL; |
} |
- |
Monitor::~Monitor() { |
DeleteCriticalSection(&data_.cs_); |
DeleteCriticalSection(&data_.waiters_cs_); |
} |
- |
void Monitor::Enter() { |
EnterCriticalSection(&data_.cs_); |
} |
- |
void Monitor::Exit() { |
LeaveCriticalSection(&data_.cs_); |
} |
- |
void MonitorWaitData::ThreadExit() { |
if (MonitorWaitData::monitor_wait_data_key_ != Thread::kUnsetThreadLocalKey) { |
uword raw_wait_data = |
@@ -213,7 +193,6 @@ void MonitorWaitData::ThreadExit() { |
} |
} |
- |
void MonitorData::AddWaiter(MonitorWaitData* wait_data) { |
// Add the MonitorWaitData object to the list of objects waiting for |
// this monitor. |
@@ -229,7 +208,6 @@ void MonitorData::AddWaiter(MonitorWaitData* wait_data) { |
LeaveCriticalSection(&waiters_cs_); |
} |
- |
void MonitorData::RemoveWaiter(MonitorWaitData* wait_data) { |
// Remove the MonitorWaitData object from the list of objects |
// waiting for this monitor. |
@@ -261,7 +239,6 @@ void MonitorData::RemoveWaiter(MonitorWaitData* wait_data) { |
LeaveCriticalSection(&waiters_cs_); |
} |
- |
void MonitorData::SignalAndRemoveFirstWaiter() { |
EnterCriticalSection(&waiters_cs_); |
MonitorWaitData* first = waiters_head_; |
@@ -284,7 +261,6 @@ void MonitorData::SignalAndRemoveFirstWaiter() { |
LeaveCriticalSection(&waiters_cs_); |
} |
- |
void MonitorData::SignalAndRemoveAllWaiters() { |
EnterCriticalSection(&waiters_cs_); |
// Extract list to signal. |
@@ -308,7 +284,6 @@ void MonitorData::SignalAndRemoveAllWaiters() { |
LeaveCriticalSection(&waiters_cs_); |
} |
- |
MonitorWaitData* MonitorData::GetMonitorWaitDataForThread() { |
// Ensure that the thread local key for monitor wait data objects is |
// initialized. |
@@ -332,7 +307,6 @@ MonitorWaitData* MonitorData::GetMonitorWaitDataForThread() { |
return wait_data; |
} |
- |
Monitor::WaitResult Monitor::Wait(int64_t millis) { |
Monitor::WaitResult retval = kNotified; |
@@ -374,7 +348,6 @@ Monitor::WaitResult Monitor::Wait(int64_t millis) { |
return retval; |
} |
- |
Monitor::WaitResult Monitor::WaitMicros(int64_t micros) { |
// TODO(johnmccutchan): Investigate sub-millisecond sleep times on Windows. |
int64_t millis = micros / kMicrosecondsPerMillisecond; |
@@ -387,12 +360,10 @@ Monitor::WaitResult Monitor::WaitMicros(int64_t micros) { |
return Wait(millis); |
} |
- |
void Monitor::Notify() { |
data_.SignalAndRemoveFirstWaiter(); |
} |
- |
void Monitor::NotifyAll() { |
// If one of the objects in the list of waiters wakes because of a |
// timeout before we signal it, that object will get an extra |