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

Side by Side Diff: runtime/vm/os_thread_win.h

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/os_thread_macos.cc ('k') | runtime/vm/os_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 RUNTIME_VM_OS_THREAD_WIN_H_ 5 #ifndef RUNTIME_VM_OS_THREAD_WIN_H_
6 #define RUNTIME_VM_OS_THREAD_WIN_H_ 6 #define RUNTIME_VM_OS_THREAD_WIN_H_
7 7
8 #if !defined(RUNTIME_VM_OS_THREAD_H_) 8 #if !defined(RUNTIME_VM_OS_THREAD_H_)
9 #error Do not include os_thread_win.h directly; use os_thread.h instead. 9 #error Do not include os_thread_win.h directly; use os_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 #include "vm/allocation.h" 15 #include "vm/allocation.h"
16 16
17 namespace dart { 17 namespace dart {
18 18
19 typedef DWORD ThreadLocalKey; 19 typedef DWORD ThreadLocalKey;
20 typedef DWORD ThreadId; 20 typedef DWORD ThreadId;
21 typedef HANDLE ThreadJoinId; 21 typedef HANDLE ThreadJoinId;
22 22
23
24 static const ThreadLocalKey kUnsetThreadLocalKey = TLS_OUT_OF_INDEXES; 23 static const ThreadLocalKey kUnsetThreadLocalKey = TLS_OUT_OF_INDEXES;
25 24
26
27 class ThreadInlineImpl { 25 class ThreadInlineImpl {
28 private: 26 private:
29 ThreadInlineImpl() {} 27 ThreadInlineImpl() {}
30 ~ThreadInlineImpl() {} 28 ~ThreadInlineImpl() {}
31 29
32 static uword GetThreadLocal(ThreadLocalKey key) { 30 static uword GetThreadLocal(ThreadLocalKey key) {
33 ASSERT(key != kUnsetThreadLocalKey); 31 ASSERT(key != kUnsetThreadLocalKey);
34 return reinterpret_cast<uword>(TlsGetValue(key)); 32 return reinterpret_cast<uword>(TlsGetValue(key));
35 } 33 }
36 34
37 friend class OSThread; 35 friend class OSThread;
38 friend unsigned int __stdcall ThreadEntry(void* data_ptr); 36 friend unsigned int __stdcall ThreadEntry(void* data_ptr);
39 37
40 DISALLOW_ALLOCATION(); 38 DISALLOW_ALLOCATION();
41 DISALLOW_COPY_AND_ASSIGN(ThreadInlineImpl); 39 DISALLOW_COPY_AND_ASSIGN(ThreadInlineImpl);
42 }; 40 };
43 41
44
45 class MutexData { 42 class MutexData {
46 private: 43 private:
47 MutexData() {} 44 MutexData() {}
48 ~MutexData() {} 45 ~MutexData() {}
49 46
50 HANDLE semaphore_; 47 HANDLE semaphore_;
51 48
52 friend class Mutex; 49 friend class Mutex;
53 50
54 DISALLOW_ALLOCATION(); 51 DISALLOW_ALLOCATION();
55 DISALLOW_COPY_AND_ASSIGN(MutexData); 52 DISALLOW_COPY_AND_ASSIGN(MutexData);
56 }; 53 };
57 54
58
59 class MonitorWaitData { 55 class MonitorWaitData {
60 public: 56 public:
61 static void ThreadExit(); 57 static void ThreadExit();
62 58
63 private: 59 private:
64 explicit MonitorWaitData(HANDLE event) : event_(event), next_(NULL) {} 60 explicit MonitorWaitData(HANDLE event) : event_(event), next_(NULL) {}
65 ~MonitorWaitData() { 61 ~MonitorWaitData() {
66 CloseHandle(event_); 62 CloseHandle(event_);
67 ASSERT(next_ == NULL); 63 ASSERT(next_ == NULL);
68 } 64 }
69 65
70 // ThreadLocalKey used to fetch and store the MonitorWaitData object 66 // ThreadLocalKey used to fetch and store the MonitorWaitData object
71 // for a given thread. 67 // for a given thread.
72 static ThreadLocalKey monitor_wait_data_key_; 68 static ThreadLocalKey monitor_wait_data_key_;
73 69
74 // Auto-reset event used for waiting. 70 // Auto-reset event used for waiting.
75 HANDLE event_; 71 HANDLE event_;
76 // Link to next element in the singly-linked list of waiters. 72 // Link to next element in the singly-linked list of waiters.
77 MonitorWaitData* next_; 73 MonitorWaitData* next_;
78 74
79 friend class Monitor; 75 friend class Monitor;
80 friend class MonitorData; 76 friend class MonitorData;
81 friend class OS; 77 friend class OS;
82 78
83
84 DISALLOW_COPY_AND_ASSIGN(MonitorWaitData); 79 DISALLOW_COPY_AND_ASSIGN(MonitorWaitData);
85 }; 80 };
86 81
87
88 class MonitorData { 82 class MonitorData {
89 private: 83 private:
90 MonitorData() {} 84 MonitorData() {}
91 ~MonitorData() {} 85 ~MonitorData() {}
92 86
93 // Helper methods to manipulate the list of waiters for this 87 // Helper methods to manipulate the list of waiters for this
94 // monitor. 88 // monitor.
95 void AddWaiter(MonitorWaitData* wait_data); 89 void AddWaiter(MonitorWaitData* wait_data);
96 void RemoveWaiter(MonitorWaitData* wait_data); 90 void RemoveWaiter(MonitorWaitData* wait_data);
97 void SignalAndRemoveFirstWaiter(); 91 void SignalAndRemoveFirstWaiter();
(...skipping 16 matching lines...) Expand all
114 MonitorWaitData* waiters_tail_; 108 MonitorWaitData* waiters_tail_;
115 109
116 friend class Monitor; 110 friend class Monitor;
117 friend class OS; 111 friend class OS;
118 friend unsigned int __stdcall ThreadEntry(void* data_ptr); 112 friend unsigned int __stdcall ThreadEntry(void* data_ptr);
119 113
120 DISALLOW_ALLOCATION(); 114 DISALLOW_ALLOCATION();
121 DISALLOW_COPY_AND_ASSIGN(MonitorData); 115 DISALLOW_COPY_AND_ASSIGN(MonitorData);
122 }; 116 };
123 117
124
125 typedef void (*ThreadDestructor)(void* parameter); 118 typedef void (*ThreadDestructor)(void* parameter);
126 119
127
128 class ThreadLocalEntry { 120 class ThreadLocalEntry {
129 public: 121 public:
130 ThreadLocalEntry(ThreadLocalKey key, ThreadDestructor destructor) 122 ThreadLocalEntry(ThreadLocalKey key, ThreadDestructor destructor)
131 : key_(key), destructor_(destructor) {} 123 : key_(key), destructor_(destructor) {}
132 124
133 ThreadLocalKey key() const { return key_; } 125 ThreadLocalKey key() const { return key_; }
134 126
135
136 ThreadDestructor destructor() const { return destructor_; } 127 ThreadDestructor destructor() const { return destructor_; }
137 128
138 private: 129 private:
139 ThreadLocalKey key_; 130 ThreadLocalKey key_;
140 ThreadDestructor destructor_; 131 ThreadDestructor destructor_;
141 132
142 DISALLOW_ALLOCATION(); 133 DISALLOW_ALLOCATION();
143 }; 134 };
144 135
145
146 template <typename T> 136 template <typename T>
147 class MallocGrowableArray; 137 class MallocGrowableArray;
148 138
149
150 class ThreadLocalData : public AllStatic { 139 class ThreadLocalData : public AllStatic {
151 public: 140 public:
152 static void RunDestructors(); 141 static void RunDestructors();
153 142
154 private: 143 private:
155 static void AddThreadLocal(ThreadLocalKey key, ThreadDestructor destructor); 144 static void AddThreadLocal(ThreadLocalKey key, ThreadDestructor destructor);
156 static void RemoveThreadLocal(ThreadLocalKey key); 145 static void RemoveThreadLocal(ThreadLocalKey key);
157 146
158 static Mutex* mutex_; 147 static Mutex* mutex_;
159 static MallocGrowableArray<ThreadLocalEntry>* thread_locals_; 148 static MallocGrowableArray<ThreadLocalEntry>* thread_locals_;
160 149
161 static void InitOnce(); 150 static void InitOnce();
162 static void Shutdown(); 151 static void Shutdown();
163 152
164 friend class OS; 153 friend class OS;
165 friend class OSThread; 154 friend class OSThread;
166 }; 155 };
167 156
168 } // namespace dart 157 } // namespace dart
169 158
170 #endif // RUNTIME_VM_OS_THREAD_WIN_H_ 159 #endif // RUNTIME_VM_OS_THREAD_WIN_H_
OLDNEW
« no previous file with comments | « runtime/vm/os_thread_macos.cc ('k') | runtime/vm/os_thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698