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

Side by Side Diff: runtime/platform/thread_win.h

Issue 25909002: Sampling profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/platform/thread_macos.cc ('k') | runtime/platform/thread_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #ifndef PLATFORM_THREAD_WIN_H_ 5 #ifndef PLATFORM_THREAD_WIN_H_
6 #define PLATFORM_THREAD_WIN_H_ 6 #define PLATFORM_THREAD_WIN_H_
7 7
8 #if !defined(PLATFORM_THREAD_H_) 8 #if !defined(PLATFORM_THREAD_H_)
9 #error Do not include thread_win.h directly; use thread.h instead. 9 #error Do not include thread_win.h directly; use thread.h instead.
10 #endif 10 #endif
11 11
12 #include "platform/assert.h" 12 #include "platform/assert.h"
13 #include "platform/globals.h" 13 #include "platform/globals.h"
14 14
15 namespace dart { 15 namespace dart {
16 16
17 typedef DWORD ThreadLocalKey; 17 typedef DWORD ThreadLocalKey;
18 typedef HANDLE ThreadId;
19
18 20
19 class ThreadInlineImpl { 21 class ThreadInlineImpl {
20 private: 22 private:
21 ThreadInlineImpl() {} 23 ThreadInlineImpl() {}
22 ~ThreadInlineImpl() {} 24 ~ThreadInlineImpl() {}
23 25
26 static ThreadLocalKey thread_id_key;
27 static ThreadId CreateThreadId();
28 static void DestroyThreadId(ThreadId);
24 static uword GetThreadLocal(ThreadLocalKey key) { 29 static uword GetThreadLocal(ThreadLocalKey key) {
25 static ThreadLocalKey kUnsetThreadLocalKey = TLS_OUT_OF_INDEXES; 30 static ThreadLocalKey kUnsetThreadLocalKey = TLS_OUT_OF_INDEXES;
26 ASSERT(key != kUnsetThreadLocalKey); 31 ASSERT(key != kUnsetThreadLocalKey);
27 return reinterpret_cast<uword>(TlsGetValue(key)); 32 return reinterpret_cast<uword>(TlsGetValue(key));
28 } 33 }
29 34
30 friend class Thread; 35 friend class Thread;
36 friend class OS;
37 friend unsigned int __stdcall ThreadEntry(void* data_ptr);
31 38
32 DISALLOW_ALLOCATION(); 39 DISALLOW_ALLOCATION();
33 DISALLOW_COPY_AND_ASSIGN(ThreadInlineImpl); 40 DISALLOW_COPY_AND_ASSIGN(ThreadInlineImpl);
34 }; 41 };
35 42
36 43
37 class MutexData { 44 class MutexData {
38 private: 45 private:
39 MutexData() {} 46 MutexData() {}
40 ~MutexData() {} 47 ~MutexData() {}
(...skipping 22 matching lines...) Expand all
63 // for a given thread. 70 // for a given thread.
64 static ThreadLocalKey monitor_wait_data_key_; 71 static ThreadLocalKey monitor_wait_data_key_;
65 72
66 // Auto-reset event used for waiting. 73 // Auto-reset event used for waiting.
67 HANDLE event_; 74 HANDLE event_;
68 // Link to next element in the singly-linked list of waiters. 75 // Link to next element in the singly-linked list of waiters.
69 MonitorWaitData* next_; 76 MonitorWaitData* next_;
70 77
71 friend class Monitor; 78 friend class Monitor;
72 friend class MonitorData; 79 friend class MonitorData;
80 friend class OS;
81
73 82
74 DISALLOW_COPY_AND_ASSIGN(MonitorWaitData); 83 DISALLOW_COPY_AND_ASSIGN(MonitorWaitData);
75 }; 84 };
76 85
77 86
78 class MonitorData { 87 class MonitorData {
79 private: 88 private:
80 MonitorData() {} 89 MonitorData() {}
81 ~MonitorData() {} 90 ~MonitorData() {}
82 91
83 // Helper methods to manipulate the list of waiters for this 92 // Helper methods to manipulate the list of waiters for this
84 // monitor. 93 // monitor.
85 void AddWaiter(MonitorWaitData* wait_data); 94 void AddWaiter(MonitorWaitData* wait_data);
86 void RemoveWaiter(MonitorWaitData* wait_data); 95 void RemoveWaiter(MonitorWaitData* wait_data);
87 void SignalAndRemoveFirstWaiter(); 96 void SignalAndRemoveFirstWaiter();
88 void SignalAndRemoveAllWaiters(); 97 void SignalAndRemoveAllWaiters();
89 MonitorWaitData* GetMonitorWaitDataForThread(); 98 static MonitorWaitData* GetMonitorWaitDataForThread();
90 99
91 // The external critical section for the monitor. 100 // The external critical section for the monitor.
92 CRITICAL_SECTION cs_; 101 CRITICAL_SECTION cs_;
93 102
94 // Condition variables are only available since Windows Vista. To 103 // Condition variables are only available since Windows Vista. To
95 // support at least Windows XP, we implement our own condition 104 // support at least Windows XP, we implement our own condition
96 // variables using SetEvent on Event objects. 105 // variables using SetEvent on Event objects.
97 106
98 // Singly-linked list of event objects, one for each thread waiting 107 // Singly-linked list of event objects, one for each thread waiting
99 // on this monitor. New waiters are added at the end of the list. 108 // on this monitor. New waiters are added at the end of the list.
100 // Notify signals the first element of the list (FIFO 109 // Notify signals the first element of the list (FIFO
101 // order). NotifyAll, signals all the elements of the list. 110 // order). NotifyAll, signals all the elements of the list.
102 CRITICAL_SECTION waiters_cs_; 111 CRITICAL_SECTION waiters_cs_;
103 MonitorWaitData* waiters_head_; 112 MonitorWaitData* waiters_head_;
104 MonitorWaitData* waiters_tail_; 113 MonitorWaitData* waiters_tail_;
105 114
106 friend class Monitor; 115 friend class Monitor;
116 friend class OS;
117 friend unsigned int __stdcall ThreadEntry(void* data_ptr);
107 118
108 DISALLOW_ALLOCATION(); 119 DISALLOW_ALLOCATION();
109 DISALLOW_COPY_AND_ASSIGN(MonitorData); 120 DISALLOW_COPY_AND_ASSIGN(MonitorData);
110 }; 121 };
111 122
112 } // namespace dart 123 } // namespace dart
113 124
114 #endif // PLATFORM_THREAD_WIN_H_ 125 #endif // PLATFORM_THREAD_WIN_H_
OLDNEW
« no previous file with comments | « runtime/platform/thread_macos.cc ('k') | runtime/platform/thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698