| Index: runtime/platform/thread_win.h
|
| diff --git a/runtime/platform/thread_win.h b/runtime/platform/thread_win.h
|
| index 02165df2fa7c2c04a0238762d055df97b6a170a9..b481cec0f63dc5b11967e197763d9ac186559ac9 100644
|
| --- a/runtime/platform/thread_win.h
|
| +++ b/runtime/platform/thread_win.h
|
| @@ -48,29 +48,53 @@ class MutexData {
|
| };
|
|
|
|
|
| +class MonitorWaitData {
|
| + private:
|
| + explicit MonitorWaitData(HANDLE event) : event_(event), next_(NULL) {}
|
| +
|
| + // ThreadLocalKey used to fetch and store the MonitorWaitData object
|
| + // for a given thread.
|
| + static ThreadLocalKey monitor_wait_data_key_;
|
| +
|
| + // Auto-reset event used for waiting.
|
| + HANDLE event_;
|
| + // Link to next element in the singly-linked list of waiters.
|
| + MonitorWaitData* next_;
|
| +
|
| + friend class Monitor;
|
| + friend class MonitorData;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(MonitorWaitData);
|
| +};
|
| +
|
| +
|
| class MonitorData {
|
| private:
|
| MonitorData() {}
|
| ~MonitorData() {}
|
|
|
| + // Helper methods to manipulate the list of waiters for this
|
| + // monitor.
|
| + void AddWaiter(MonitorWaitData* wait_data);
|
| + void RemoveWaiter(MonitorWaitData* wait_data);
|
| + void SignalAndRemoveFirstWaiter();
|
| + void SignalAndRemoveAllWaiters();
|
| + MonitorWaitData* GetMonitorWaitDataForThread();
|
| +
|
| + // The external critical section for the monitor.
|
| CRITICAL_SECTION cs_;
|
|
|
| // Condition variables are only available since Windows Vista. To
|
| // support at least Windows XP, we implement our own condition
|
| // variables using SetEvent on Event objects.
|
|
|
| - // The notify_event_ is an auto-reset event which means that
|
| - // SetEvent only wakes up one waiter.
|
| - HANDLE notify_event_;
|
| -
|
| - // The notify_all_event_ is a manual-reset event which means that
|
| - // SetEvent wakes up all waiters.
|
| - HANDLE notify_all_event_;
|
| -
|
| - // Counter with protection used to determine the right time to reset
|
| - // the notify_all_event_.
|
| + // Singly-linked list of event objects, one for each thread waiting
|
| + // on this monitor. New waiters are added at the end of the list.
|
| + // Notify signals the first element of the list (FIFO
|
| + // order). NotifyAll, signals all the elements of the list.
|
| CRITICAL_SECTION waiters_cs_;
|
| - intptr_t waiters_;
|
| + MonitorWaitData* waiters_head_;
|
| + MonitorWaitData* waiters_tail_;
|
|
|
| friend class Monitor;
|
|
|
|
|