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

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

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 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
« no previous file with comments | « runtime/vm/os_macos.cc ('k') | runtime/vm/os_thread.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_H_ 5 #ifndef RUNTIME_VM_OS_THREAD_H_
6 #define RUNTIME_VM_OS_THREAD_H_ 6 #define RUNTIME_VM_OS_THREAD_H_
7 7
8 #include "platform/globals.h" 8 #include "platform/globals.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return id_; 63 return id_;
64 } 64 }
65 65
66 #ifndef PRODUCT 66 #ifndef PRODUCT
67 ThreadId trace_id() const { 67 ThreadId trace_id() const {
68 ASSERT(trace_id_ != OSThread::kInvalidThreadId); 68 ASSERT(trace_id_ != OSThread::kInvalidThreadId);
69 return trace_id_; 69 return trace_id_;
70 } 70 }
71 #endif 71 #endif
72 72
73 const char* name() const { 73 const char* name() const { return name_; }
74 return name_;
75 }
76 74
77 void SetName(const char* name); 75 void SetName(const char* name);
78 76
79 void set_name(const char* name) { 77 void set_name(const char* name) {
80 ASSERT(OSThread::Current() == this); 78 ASSERT(OSThread::Current() == this);
81 ASSERT(name_ == NULL); 79 ASSERT(name_ == NULL);
82 ASSERT(name != NULL); 80 ASSERT(name != NULL);
83 name_ = strdup(name); 81 name_ = strdup(name);
84 } 82 }
85 83
86 Mutex* timeline_block_lock() const { 84 Mutex* timeline_block_lock() const { return timeline_block_lock_; }
87 return timeline_block_lock_;
88 }
89 85
90 // Only safe to access when holding |timeline_block_lock_|. 86 // Only safe to access when holding |timeline_block_lock_|.
91 TimelineEventBlock* timeline_block() const { 87 TimelineEventBlock* timeline_block() const { return timeline_block_; }
92 return timeline_block_;
93 }
94 88
95 // Only safe to access when holding |timeline_block_lock_|. 89 // Only safe to access when holding |timeline_block_lock_|.
96 void set_timeline_block(TimelineEventBlock* block) { 90 void set_timeline_block(TimelineEventBlock* block) {
97 timeline_block_ = block; 91 timeline_block_ = block;
98 } 92 }
99 93
100 Log* log() const { return log_; } 94 Log* log() const { return log_; }
101 95
102 uword stack_base() const { return stack_base_; } 96 uword stack_base() const { return stack_base_; }
103 void set_stack_base(uword stack_base) { stack_base_ = stack_base; } 97 void set_stack_base(uword stack_base) { stack_base_ = stack_base; }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // TODO(5411455): Use flag to override default value and Validate the 134 // TODO(5411455): Use flag to override default value and Validate the
141 // stack size by querying OS. 135 // stack size by querying OS.
142 static uword GetSpecifiedStackSize() { 136 static uword GetSpecifiedStackSize() {
143 ASSERT(OSThread::kStackSizeBuffer < OSThread::GetMaxStackSize()); 137 ASSERT(OSThread::kStackSizeBuffer < OSThread::GetMaxStackSize());
144 uword stack_size = OSThread::GetMaxStackSize() - OSThread::kStackSizeBuffer; 138 uword stack_size = OSThread::GetMaxStackSize() - OSThread::kStackSizeBuffer;
145 return stack_size; 139 return stack_size;
146 } 140 }
147 static BaseThread* GetCurrentTLS() { 141 static BaseThread* GetCurrentTLS() {
148 return reinterpret_cast<BaseThread*>(OSThread::GetThreadLocal(thread_key_)); 142 return reinterpret_cast<BaseThread*>(OSThread::GetThreadLocal(thread_key_));
149 } 143 }
150 static void SetCurrentTLS(uword value) { 144 static void SetCurrentTLS(uword value) { SetThreadLocal(thread_key_, value); }
151 SetThreadLocal(thread_key_, value);
152 }
153 145
154 typedef void (*ThreadStartFunction) (uword parameter); 146 typedef void (*ThreadStartFunction)(uword parameter);
155 typedef void (*ThreadDestructor) (void* parameter); 147 typedef void (*ThreadDestructor)(void* parameter);
156 148
157 // Start a thread running the specified function. Returns 0 if the 149 // Start a thread running the specified function. Returns 0 if the
158 // thread started successfuly and a system specific error code if 150 // thread started successfuly and a system specific error code if
159 // the thread failed to start. 151 // the thread failed to start.
160 static int Start( 152 static int Start(const char* name,
161 const char* name, ThreadStartFunction function, uword parameter); 153 ThreadStartFunction function,
154 uword parameter);
162 155
163 static ThreadLocalKey CreateThreadLocal(ThreadDestructor destructor = NULL); 156 static ThreadLocalKey CreateThreadLocal(ThreadDestructor destructor = NULL);
164 static void DeleteThreadLocal(ThreadLocalKey key); 157 static void DeleteThreadLocal(ThreadLocalKey key);
165 static uword GetThreadLocal(ThreadLocalKey key) { 158 static uword GetThreadLocal(ThreadLocalKey key) {
166 return ThreadInlineImpl::GetThreadLocal(key); 159 return ThreadInlineImpl::GetThreadLocal(key);
167 } 160 }
168 static ThreadId GetCurrentThreadId(); 161 static ThreadId GetCurrentThreadId();
169 static void SetThreadLocal(ThreadLocalKey key, uword value); 162 static void SetThreadLocal(ThreadLocalKey key, uword value);
170 static intptr_t GetMaxStackSize(); 163 static intptr_t GetMaxStackSize();
171 static void Join(ThreadJoinId id); 164 static void Join(ThreadJoinId id);
(...skipping 23 matching lines...) Expand all
195 // to create a new OSThread structure. 188 // to create a new OSThread structure.
196 OSThread(); 189 OSThread();
197 190
198 // These methods should not be used in a generic way and hence 191 // These methods should not be used in a generic way and hence
199 // are private, they have been added to solve the problem of 192 // are private, they have been added to solve the problem of
200 // accessing the VM thread structure from an OSThread object 193 // accessing the VM thread structure from an OSThread object
201 // in the windows thread interrupter which is used for profiling. 194 // in the windows thread interrupter which is used for profiling.
202 // We could eliminate this requirement if the windows thread interrupter 195 // We could eliminate this requirement if the windows thread interrupter
203 // is implemented differently. 196 // is implemented differently.
204 Thread* thread() const { return thread_; } 197 Thread* thread() const { return thread_; }
205 void set_thread(Thread* value) { 198 void set_thread(Thread* value) { thread_ = value; }
206 thread_ = value;
207 }
208 199
209 static void Cleanup(); 200 static void Cleanup();
210 #ifndef PRODUCT 201 #ifndef PRODUCT
211 static ThreadId GetCurrentThreadTraceId(); 202 static ThreadId GetCurrentThreadTraceId();
212 #endif // PRODUCT 203 #endif // PRODUCT
213 static OSThread* GetOSThreadFromThread(Thread* thread); 204 static OSThread* GetOSThreadFromThread(Thread* thread);
214 static void AddThreadToListLocked(OSThread* thread); 205 static void AddThreadToListLocked(OSThread* thread);
215 static void RemoveThreadFromList(OSThread* thread); 206 static void RemoveThreadFromList(OSThread* thread);
216 static OSThread* CreateAndSetUnknownThread(); 207 static OSThread* CreateAndSetUnknownThread();
217 208
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 friend class TimelineEventBlockIterator; 295 friend class TimelineEventBlockIterator;
305 friend class TimelineEventRecorder; 296 friend class TimelineEventRecorder;
306 friend class PageSpace; 297 friend class PageSpace;
307 friend void Dart_TestMutex(); 298 friend void Dart_TestMutex();
308 DISALLOW_COPY_AND_ASSIGN(Mutex); 299 DISALLOW_COPY_AND_ASSIGN(Mutex);
309 }; 300 };
310 301
311 302
312 class Monitor { 303 class Monitor {
313 public: 304 public:
314 enum WaitResult { 305 enum WaitResult { kNotified, kTimedOut };
315 kNotified,
316 kTimedOut
317 };
318 306
319 static const int64_t kNoTimeout = 0; 307 static const int64_t kNoTimeout = 0;
320 308
321 Monitor(); 309 Monitor();
322 ~Monitor(); 310 ~Monitor();
323 311
324 #if defined(DEBUG) 312 #if defined(DEBUG)
325 bool IsOwnedByCurrentThread() const { 313 bool IsOwnedByCurrentThread() const {
326 return owner_ == OSThread::GetCurrentThreadId(); 314 return owner_ == OSThread::GetCurrentThreadId();
327 } 315 }
(...skipping 26 matching lines...) Expand all
354 friend class SafepointMonitorLocker; 342 friend class SafepointMonitorLocker;
355 friend void Dart_TestMonitor(); 343 friend void Dart_TestMonitor();
356 DISALLOW_COPY_AND_ASSIGN(Monitor); 344 DISALLOW_COPY_AND_ASSIGN(Monitor);
357 }; 345 };
358 346
359 347
360 } // namespace dart 348 } // namespace dart
361 349
362 350
363 #endif // RUNTIME_VM_OS_THREAD_H_ 351 #endif // RUNTIME_VM_OS_THREAD_H_
OLDNEW
« no previous file with comments | « runtime/vm/os_macos.cc ('k') | runtime/vm/os_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698