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

Unified Diff: runtime/vm/thread.h

Issue 1041523002: Refactor Thread lifecycle interface, add Thread::Enter/ExitIsolate. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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/service_isolate.cc ('k') | runtime/vm/thread.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/thread.h
===================================================================
--- runtime/vm/thread.h (revision 44762)
+++ runtime/vm/thread.h (working copy)
@@ -15,20 +15,29 @@
class Isolate;
// A VM thread; may be executing Dart code or performing helper tasks like
-// garbage collection or compilation.
+// garbage collection or compilation. The Thread structure associated with
+// a thread is allocated when the thread enters an isolate, and destroyed
+// upon exiting an isolate or an explicit call to CleanUp.
class Thread {
public:
- explicit Thread(Isolate* isolate)
- : isolate_(isolate),
- cha_(NULL) {}
-
- static void InitOnce();
-
+ // The currently executing thread, or NULL if not yet initialized.
static Thread* Current() {
return reinterpret_cast<Thread*>(OSThread::GetThreadLocal(thread_key_));
}
- static void SetCurrent(Thread* current);
+ // Makes the current thread enter 'isolate'. Also calls EnsureInit.
+ static void EnterIsolate(Isolate* isolate);
+ // Makes the current thread exit its isolate. Also calls CleanUp.
+ static void ExitIsolate();
+
+ // Initializes the current thread as a VM thread, if not already done.
+ static void EnsureInit();
+ // Clears the state of the current thread.
+ static void CleanUp();
+
+ // Called at VM startup.
+ static void InitOnce();
+
// The topmost zone used for allocation in this thread.
Zone* zone() {
return reinterpret_cast<BaseIsolate*>(isolate())->current_zone();
@@ -47,6 +56,12 @@
Isolate* isolate_;
CHA* cha_;
+ Thread()
+ : isolate_(NULL),
+ cha_(NULL) {}
+
+ static void SetCurrent(Thread* current);
+
DISALLOW_COPY_AND_ASSIGN(Thread);
};
« no previous file with comments | « runtime/vm/service_isolate.cc ('k') | runtime/vm/thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698