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

Unified Diff: runtime/vm/thread_interrupter.h

Issue 128653004: Use list of isolates in profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/profiler.cc ('k') | runtime/vm/thread_interrupter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/thread_interrupter.h
diff --git a/runtime/vm/thread_interrupter.h b/runtime/vm/thread_interrupter.h
index 3a3168399578523ae07f947c8b28aa2cfee8e35b..30bc4a879f340250e8fbe12ad471ba65750e68ab 100644
--- a/runtime/vm/thread_interrupter.h
+++ b/runtime/vm/thread_interrupter.h
@@ -30,9 +30,19 @@ struct InterruptedThreadState {
typedef void (*ThreadInterruptCallback)(const InterruptedThreadState& state,
void* data);
+// State stored per registered thread.
+class InterruptableThreadState {
+ public:
+ ThreadId id;
+ ThreadInterruptCallback callback;
+ void* data;
+};
+
class ThreadInterrupter : public AllStatic {
public:
static void InitOnce();
+
+ static void Startup();
static void Shutdown();
// Delay between interrupts.
@@ -40,14 +50,16 @@ class ThreadInterrupter : public AllStatic {
// Register the currently running thread for interrupts. If the current thread
// is already registered, callback and data will be updated.
- static void Register(ThreadInterruptCallback callback, void* data);
+ static InterruptableThreadState* Register(ThreadInterruptCallback callback,
+ void* data);
// Unregister the currently running thread for interrupts.
static void Unregister();
- // Enable interrupts for this thread. Does not alter callback.
- static void Enable();
- // Disable interrupts for this thread. Does not alter callback.
- static void Disable();
+ // Get the current thread state. Will create a thread state if one hasn't
+ // been allocated.
+ static InterruptableThreadState* GetCurrentThreadState();
+ // Get the current thread state. Will not create one if one doesn't exist.
+ static InterruptableThreadState* CurrentThreadState();
private:
static const intptr_t kMaxThreads = 4096;
@@ -58,38 +70,18 @@ class ThreadInterrupter : public AllStatic {
static Monitor* monitor_;
static intptr_t interrupt_period_;
static ThreadLocalKey thread_state_key_;
- // State stored per registered thread.
- struct ThreadState {
- ThreadId id;
- ThreadInterruptCallback callback;
- void* data;
- };
+ static InterruptableThreadState* _EnsureThreadStateCreated();
static void UpdateStateObject(ThreadInterruptCallback callback, void* data);
- static ThreadState* CurrentThreadState();
- static void SetCurrentThreadState(ThreadState* state);
-
- // Registered thread table.
- static ThreadState** threads_;
- static intptr_t threads_capacity_;
- static intptr_t threads_size_;
- static void _EnsureThreadStateCreated();
- static void _Enable();
- static void _Disable();
- static void ResizeThreads(intptr_t new_capacity);
- static void AddThread(ThreadId id);
- static intptr_t FindThreadIndex(ThreadId id);
- static ThreadState* RemoveThread(intptr_t i);
-
- friend class ThreadInterrupterAndroid;
- friend class ThreadInterrupterMacOS;
- friend class ThreadInterrupterLinux;
- friend class ThreadInterrupterWin;
-
- static void InterruptThreads(int64_t current_time);
+
+ static void SetCurrentThreadState(InterruptableThreadState* state);
+
+ static void InterruptThread(InterruptableThreadState* thread_state);
static void ThreadMain(uword parameters);
static void InstallSignalHandler();
+
+ friend class ThreadInterrupterVisitIsolates;
};
void ThreadInterruptNoOp(const InterruptedThreadState& state, void* data);
« no previous file with comments | « runtime/vm/profiler.cc ('k') | runtime/vm/thread_interrupter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698