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

Unified Diff: runtime/vm/thread.cc

Issue 1134003005: Automatic thread cleanup on non-Windows platforms. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 7 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/thread.h ('k') | runtime/vm/thread_pool.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/thread.cc
===================================================================
--- runtime/vm/thread.cc (revision 45815)
+++ runtime/vm/thread.cc (working copy)
@@ -18,9 +18,14 @@
ThreadLocalKey Thread::thread_key_ = OSThread::kUnsetThreadLocalKey;
+static void DeleteThread(void* thread) {
+ delete reinterpret_cast<Thread*>(thread);
+}
+
+
void Thread::InitOnce() {
ASSERT(thread_key_ == OSThread::kUnsetThreadLocalKey);
- thread_key_ = OSThread::CreateThreadLocal();
+ thread_key_ = OSThread::CreateThreadLocal(DeleteThread);
ASSERT(thread_key_ != OSThread::kUnsetThreadLocalKey);
}
@@ -37,6 +42,7 @@
}
+#if defined(TARGET_OS_WINDOWS)
void Thread::CleanUp() {
Thread* current = Current();
if (current != NULL) {
@@ -44,11 +50,12 @@
}
SetCurrent(NULL);
}
+#endif
void Thread::EnterIsolate(Isolate* isolate) {
- EnsureInit();
Thread* thread = Thread::Current();
+ ASSERT(thread != NULL);
ASSERT(thread->isolate() == NULL);
ASSERT(isolate->mutator_thread() == NULL);
thread->isolate_ = isolate;
@@ -87,8 +94,8 @@
void Thread::EnterIsolateAsHelper(Isolate* isolate) {
- EnsureInit();
Thread* thread = Thread::Current();
+ ASSERT(thread != NULL);
ASSERT(thread->isolate() == NULL);
thread->isolate_ = isolate;
// Do not update isolate->mutator_thread, but perform sanity check:
« no previous file with comments | « runtime/vm/thread.h ('k') | runtime/vm/thread_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698