Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(800)

Unified Diff: runtime/platform/thread_win.h

Issue 9424050: Reimplement Windows Monitors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix timeout handling. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/platform/thread_win.cc » ('j') | runtime/platform/thread_win.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/thread_win.h
diff --git a/runtime/platform/thread_win.h b/runtime/platform/thread_win.h
index 02165df2fa7c2c04a0238762d055df97b6a170a9..978e73fe9140ccd3a283f2573153c2f3c0af109c 100644
--- a/runtime/platform/thread_win.h
+++ b/runtime/platform/thread_win.h
@@ -48,28 +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_;
cshapiro 2012/02/21 18:49:36 This event handle should be stored in Thread there
Mads Ager (google) 2012/02/22 12:32:51 I don't understand. I allocate exactly one event p
+ // 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);
+ MonitorWaitData* RemoveFirstWaiter();
+ MonitorWaitData** RemoveAllWaiters();
+ 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.
cshapiro 2012/02/21 18:49:36 This behavior is not performance sensitive. Notif
Mads Ager (google) 2012/02/22 12:32:51 This design does sound nice. I would like to go wi
CRITICAL_SECTION waiters_cs_;
+ MonitorWaitData* waiters_head_;
+ MonitorWaitData* waiters_tail_;
intptr_t waiters_;
friend class Monitor;
« no previous file with comments | « no previous file | runtime/platform/thread_win.cc » ('j') | runtime/platform/thread_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698