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

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

Issue 1537543002: Fix for issue 25236 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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
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"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 friend class Thread; 43 friend class Thread;
44 friend class OSThread; 44 friend class OSThread;
45 45
46 DISALLOW_IMPLICIT_CONSTRUCTORS(BaseThread); 46 DISALLOW_IMPLICIT_CONSTRUCTORS(BaseThread);
47 }; 47 };
48 48
49 49
50 // Low-level operations on OS platform threads. 50 // Low-level operations on OS platform threads.
51 class OSThread : public BaseThread { 51 class OSThread : public BaseThread {
52 public: 52 public:
53 OSThread();
54 ~OSThread(); 53 ~OSThread();
55 54
56 ThreadId id() const { 55 ThreadId id() const {
57 ASSERT(id_ != OSThread::kInvalidThreadId); 56 ASSERT(id_ != OSThread::kInvalidThreadId);
58 return id_; 57 return id_;
59 } 58 }
60 59
61 ThreadJoinId join_id() const { 60 ThreadJoinId join_id() const {
62 ASSERT(join_id_ != OSThread::kInvalidThreadJoinId); 61 ASSERT(join_id_ != OSThread::kInvalidThreadJoinId);
63 return join_id_; 62 return join_id_;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 162 }
164 static ThreadId GetCurrentThreadId(); 163 static ThreadId GetCurrentThreadId();
165 static void SetThreadLocal(ThreadLocalKey key, uword value); 164 static void SetThreadLocal(ThreadLocalKey key, uword value);
166 static intptr_t GetMaxStackSize(); 165 static intptr_t GetMaxStackSize();
167 static void Join(ThreadJoinId id); 166 static void Join(ThreadJoinId id);
168 static intptr_t ThreadIdToIntPtr(ThreadId id); 167 static intptr_t ThreadIdToIntPtr(ThreadId id);
169 static ThreadId ThreadIdFromIntPtr(intptr_t id); 168 static ThreadId ThreadIdFromIntPtr(intptr_t id);
170 static bool Compare(ThreadId a, ThreadId b); 169 static bool Compare(ThreadId a, ThreadId b);
171 static void GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage); 170 static void GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage);
172 171
172 static OSThread* CreateOSThread();
zra 2015/12/17 16:37:59 Maybe this should go up at the top of the class wh
siva 2015/12/17 18:19:13 Done.
173
173 // Called at VM startup and shutdown. 174 // Called at VM startup and shutdown.
174 static void InitOnce(); 175 static void InitOnce();
175 176
176 static bool IsThreadInList(ThreadJoinId join_id); 177 static bool IsThreadInList(ThreadJoinId join_id);
177 178
179 static void DisableOSThreadCreation();
180 static void EnableOSThreadCreation();
181
178 static const intptr_t kStackSizeBuffer = (4 * KB * kWordSize); 182 static const intptr_t kStackSizeBuffer = (4 * KB * kWordSize);
179 183
180 static const ThreadId kInvalidThreadId; 184 static const ThreadId kInvalidThreadId;
181 static const ThreadJoinId kInvalidThreadJoinId; 185 static const ThreadJoinId kInvalidThreadJoinId;
182 186
183 private: 187 private:
188 // The constructor is private as CreateOSThread should be used
189 // to create a new OSThread structure.
190 OSThread();
191
184 // These methods should not be used in a generic way and hence 192 // These methods should not be used in a generic way and hence
185 // are private, they have been added to solve the problem of 193 // are private, they have been added to solve the problem of
186 // accessing the VM thread structure from an OSThread object 194 // accessing the VM thread structure from an OSThread object
187 // in the windows thread interrupter which is used for profiling. 195 // in the windows thread interrupter which is used for profiling.
188 // We could eliminate this requirement if the windows thread interrupter 196 // We could eliminate this requirement if the windows thread interrupter
189 // is implemented differently. 197 // is implemented differently.
190 Thread* thread() const { return thread_; } 198 Thread* thread() const { return thread_; }
191 void set_thread(Thread* value) { 199 void set_thread(Thread* value) {
192 thread_ = value; 200 thread_ = value;
193 } 201 }
(...skipping 19 matching lines...) Expand all
213 // All |Thread|s are registered in the thread list. 221 // All |Thread|s are registered in the thread list.
214 OSThread* thread_list_next_; 222 OSThread* thread_list_next_;
215 223
216 uintptr_t thread_interrupt_disabled_; 224 uintptr_t thread_interrupt_disabled_;
217 Log* log_; 225 Log* log_;
218 uword stack_base_; 226 uword stack_base_;
219 Thread* thread_; 227 Thread* thread_;
220 228
221 static OSThread* thread_list_head_; 229 static OSThread* thread_list_head_;
222 static Mutex* thread_list_lock_; 230 static Mutex* thread_list_lock_;
231 static bool creation_enabled_;
223 232
224 friend class OSThreadIterator; 233 friend class OSThreadIterator;
225 friend class ThreadInterrupterWin; 234 friend class ThreadInterrupterWin;
226 friend class ThreadRegistry; 235 friend class ThreadRegistry;
227 }; 236 };
228 237
229 238
230 // Note that this takes the thread list lock, prohibiting threads from coming 239 // Note that this takes the thread list lock, prohibiting threads from coming
231 // on- or off-line. 240 // on- or off-line.
232 class OSThreadIterator : public ValueObject { 241 class OSThreadIterator : public ValueObject {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 #endif // defined(DEBUG) 325 #endif // defined(DEBUG)
317 326
318 DISALLOW_COPY_AND_ASSIGN(Monitor); 327 DISALLOW_COPY_AND_ASSIGN(Monitor);
319 }; 328 };
320 329
321 330
322 } // namespace dart 331 } // namespace dart
323 332
324 333
325 #endif // VM_OS_THREAD_H_ 334 #endif // VM_OS_THREAD_H_
OLDNEW
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/os_thread.cc » ('j') | runtime/vm/os_thread.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698