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

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

Issue 2117593002: Fuchsia: Initial check-in. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 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_fuchsia.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 VM_OS_THREAD_H_ 5 #ifndef VM_OS_THREAD_H_
6 #define VM_OS_THREAD_H_ 6 #define 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"
11 11
12 // Declare the OS-specific types ahead of defining the generic classes. 12 // Declare the OS-specific types ahead of defining the generic classes.
13 #if defined(TARGET_OS_ANDROID) 13 #if defined(TARGET_OS_ANDROID)
14 #include "vm/os_thread_android.h" 14 #include "vm/os_thread_android.h"
15 #elif defined(TARGET_OS_FUCHSIA)
16 #include "vm/os_thread_fuchsia.h"
15 #elif defined(TARGET_OS_LINUX) 17 #elif defined(TARGET_OS_LINUX)
16 #include "vm/os_thread_linux.h" 18 #include "vm/os_thread_linux.h"
17 #elif defined(TARGET_OS_MACOS) 19 #elif defined(TARGET_OS_MACOS)
18 #include "vm/os_thread_macos.h" 20 #include "vm/os_thread_macos.h"
19 #elif defined(TARGET_OS_WINDOWS) 21 #elif defined(TARGET_OS_WINDOWS)
20 #include "vm/os_thread_win.h" 22 #include "vm/os_thread_win.h"
21 #else 23 #else
22 #error Unknown target os. 24 #error Unknown target os.
23 #endif 25 #endif
24 26
(...skipping 29 matching lines...) Expand all
54 // this factory style method 'CreateOSThread' to create OSThread structures. 56 // this factory style method 'CreateOSThread' to create OSThread structures.
55 // The method can return a NULL if the Dart VM is in shutdown mode. 57 // The method can return a NULL if the Dart VM is in shutdown mode.
56 static OSThread* CreateOSThread(); 58 static OSThread* CreateOSThread();
57 ~OSThread(); 59 ~OSThread();
58 60
59 ThreadId id() const { 61 ThreadId id() const {
60 ASSERT(id_ != OSThread::kInvalidThreadId); 62 ASSERT(id_ != OSThread::kInvalidThreadId);
61 return id_; 63 return id_;
62 } 64 }
63 65
66 #ifndef PRODUCT
64 ThreadId trace_id() const { 67 ThreadId trace_id() const {
65 ASSERT(trace_id_ != OSThread::kInvalidThreadId); 68 ASSERT(trace_id_ != OSThread::kInvalidThreadId);
66 return trace_id_; 69 return trace_id_;
67 } 70 }
71 #endif
68 72
69 const char* name() const { 73 const char* name() const {
70 return name_; 74 return name_;
71 } 75 }
72 76
73 void SetName(const char* name); 77 void SetName(const char* name);
74 78
75 void set_name(const char* name) { 79 void set_name(const char* name) {
76 ASSERT(OSThread::Current() == this); 80 ASSERT(OSThread::Current() == this);
77 ASSERT(name_ == NULL); 81 ASSERT(name_ == NULL);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // accessing the VM thread structure from an OSThread object 200 // accessing the VM thread structure from an OSThread object
197 // in the windows thread interrupter which is used for profiling. 201 // in the windows thread interrupter which is used for profiling.
198 // We could eliminate this requirement if the windows thread interrupter 202 // We could eliminate this requirement if the windows thread interrupter
199 // is implemented differently. 203 // is implemented differently.
200 Thread* thread() const { return thread_; } 204 Thread* thread() const { return thread_; }
201 void set_thread(Thread* value) { 205 void set_thread(Thread* value) {
202 thread_ = value; 206 thread_ = value;
203 } 207 }
204 208
205 static void Cleanup(); 209 static void Cleanup();
210 #ifndef PRODUCT
206 static ThreadId GetCurrentThreadTraceId(); 211 static ThreadId GetCurrentThreadTraceId();
212 #endif // PRODUCT
207 static OSThread* GetOSThreadFromThread(Thread* thread); 213 static OSThread* GetOSThreadFromThread(Thread* thread);
208 static void AddThreadToListLocked(OSThread* thread); 214 static void AddThreadToListLocked(OSThread* thread);
209 static void RemoveThreadFromList(OSThread* thread); 215 static void RemoveThreadFromList(OSThread* thread);
210 static OSThread* CreateAndSetUnknownThread(); 216 static OSThread* CreateAndSetUnknownThread();
211 217
212 static ThreadLocalKey thread_key_; 218 static ThreadLocalKey thread_key_;
213 219
214 const ThreadId id_; 220 const ThreadId id_;
215 #if defined(DEBUG) 221 #if defined(DEBUG)
216 // In DEBUG mode we use this field to ensure that GetCurrentThreadJoinId is 222 // In DEBUG mode we use this field to ensure that GetCurrentThreadJoinId is
217 // only called once per OSThread. 223 // only called once per OSThread.
218 ThreadJoinId join_id_; 224 ThreadJoinId join_id_;
219 #endif 225 #endif
226 #ifndef PRODUCT
220 const ThreadId trace_id_; // Used to interface with tracing tools. 227 const ThreadId trace_id_; // Used to interface with tracing tools.
228 #endif
221 char* name_; // A name for this thread. 229 char* name_; // A name for this thread.
222 230
223 Mutex* timeline_block_lock_; 231 Mutex* timeline_block_lock_;
224 TimelineEventBlock* timeline_block_; 232 TimelineEventBlock* timeline_block_;
225 233
226 // All |Thread|s are registered in the thread list. 234 // All |Thread|s are registered in the thread list.
227 OSThread* thread_list_next_; 235 OSThread* thread_list_next_;
228 236
229 uintptr_t thread_interrupt_disabled_; 237 uintptr_t thread_interrupt_disabled_;
230 Log* log_; 238 Log* log_;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 friend class SafepointMonitorLocker; 354 friend class SafepointMonitorLocker;
347 friend void Dart_TestMonitor(); 355 friend void Dart_TestMonitor();
348 DISALLOW_COPY_AND_ASSIGN(Monitor); 356 DISALLOW_COPY_AND_ASSIGN(Monitor);
349 }; 357 };
350 358
351 359
352 } // namespace dart 360 } // namespace dart
353 361
354 362
355 #endif // VM_OS_THREAD_H_ 363 #endif // VM_OS_THREAD_H_
OLDNEW
« no previous file with comments | « runtime/vm/os_fuchsia.cc ('k') | runtime/vm/os_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698