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

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

Issue 1423473004: Switch profiler from isolates to threads [second landing] (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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/thread.cc ('k') | runtime/vm/thread_interrupter.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_THREAD_INTERRUPTER_H_ 5 #ifndef VM_THREAD_INTERRUPTER_H_
6 #define VM_THREAD_INTERRUPTER_H_ 6 #define VM_THREAD_INTERRUPTER_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/signal_handler.h" 9 #include "vm/signal_handler.h"
10 #include "vm/os_thread.h" 10 #include "vm/os_thread.h"
11 #include "vm/thread.h" 11 #include "vm/thread.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 class ThreadInterrupter : public AllStatic { 15 class ThreadInterrupter : public AllStatic {
16 public: 16 public:
17 static void InitOnce(); 17 static void InitOnce();
18 18
19 static void Startup(); 19 static void Startup();
20 static void Shutdown(); 20 static void Shutdown();
21 21
22 // Delay between interrupts. 22 // Delay between interrupts.
23 static void SetInterruptPeriod(intptr_t period); 23 static void SetInterruptPeriod(intptr_t period);
24 24
25 // Wake up the thread interrupter thread. 25 // Wake up the thread interrupter thread.
26 static void WakeUp(); 26 static void WakeUp();
27 27
28 // Register the currently running thread for interrupts. If the current thread
29 // is already registered, callback and data will be updated.
30 static void Register(ThreadInterruptCallback callback, void* data);
31
32 // Unregister the currently running thread for interrupts.
33 static void Unregister();
34
35 // Interrupt a thread. 28 // Interrupt a thread.
36 static void InterruptThread(Thread* thread); 29 static void InterruptThread(Thread* thread);
37 30
38 private: 31 private:
39 static const intptr_t kMaxThreads = 4096; 32 static const intptr_t kMaxThreads = 4096;
40 static bool initialized_; 33 static bool initialized_;
41 static bool shutdown_; 34 static bool shutdown_;
42 static bool thread_running_; 35 static bool thread_running_;
36 static bool woken_up_;
43 static ThreadJoinId interrupter_thread_id_; 37 static ThreadJoinId interrupter_thread_id_;
44 static Monitor* monitor_; 38 static Monitor* monitor_;
45 static intptr_t interrupt_period_; 39 static intptr_t interrupt_period_;
46 static intptr_t current_wait_time_; 40 static intptr_t current_wait_time_;
47 41
48 static bool InDeepSleep() { 42 static bool InDeepSleep() {
49 return current_wait_time_ == Monitor::kNoTimeout; 43 return current_wait_time_ == Monitor::kNoTimeout;
50 } 44 }
51 45
52 static void UpdateStateObject(ThreadInterruptCallback callback, void* data); 46 static void UpdateStateObject(ThreadInterruptCallback callback, void* data);
53 47
54 static void ThreadMain(uword parameters); 48 static void ThreadMain(uword parameters);
55 49
56 static void InstallSignalHandler(); 50 static void InstallSignalHandler();
57 51
58 static void RemoveSignalHandler(); 52 static void RemoveSignalHandler();
59 53
60 friend class ThreadInterrupterVisitIsolates; 54 friend class ThreadInterrupterVisitIsolates;
61 }; 55 };
62 56
63 void ThreadInterruptNoOp(const InterruptedThreadState& state, void* data);
64
65 } // namespace dart 57 } // namespace dart
66 58
67 #endif // VM_THREAD_INTERRUPTER_H_ 59 #endif // VM_THREAD_INTERRUPTER_H_
OLDNEW
« no previous file with comments | « runtime/vm/thread.cc ('k') | runtime/vm/thread_interrupter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698