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

Unified Diff: runtime/vm/thread_interrupter.cc

Issue 1293253005: Completely remove InterruptableThreadState and Fix ThreadRegistry leak (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
Index: runtime/vm/thread_interrupter.cc
diff --git a/runtime/vm/thread_interrupter.cc b/runtime/vm/thread_interrupter.cc
index 23e6c22fc4df17365db199763c694b035edc0769..0cf7c3814b1badcc1a8c839c3ecdaef9730b872b 100644
--- a/runtime/vm/thread_interrupter.cc
+++ b/runtime/vm/thread_interrupter.cc
@@ -148,93 +148,6 @@ void ThreadInterrupter::WakeUp() {
}
}
-// Register the currently running thread for interrupts. If the current thread
-// is already registered, callback and data will be updated.
-InterruptableThreadState* ThreadInterrupter::Register(
- ThreadInterruptCallback callback, void* data) {
- if (shutdown_) {
- return NULL;
- }
- ASSERT(initialized_);
- InterruptableThreadState* state = _EnsureThreadStateCreated();
- // Set callback and data.
- UpdateStateObject(callback, data);
- return state;
-}
-
-
-// Unregister the currently running thread for interrupts.
-void ThreadInterrupter::Unregister() {
- if (shutdown_) {
- return;
- }
- ASSERT(initialized_);
- _EnsureThreadStateCreated();
- // Clear callback and data.
- UpdateStateObject(NULL, NULL);
-}
-
-
-InterruptableThreadState* ThreadInterrupter::_EnsureThreadStateCreated() {
- InterruptableThreadState* state = CurrentThreadState();
- if (state == NULL) {
- // Create thread state object lazily.
- ThreadId current_thread = OSThread::GetCurrentThreadId();
- if (FLAG_trace_thread_interrupter) {
- intptr_t tid = OSThread::ThreadIdToIntPtr(current_thread);
- OS::Print("ThreadInterrupter Tracking %p\n",
- reinterpret_cast<void*>(tid));
- }
- // Note: We currently do not free a thread's InterruptableThreadState.
- state = new InterruptableThreadState();
- ASSERT(state != NULL);
- state->callback = NULL;
- state->data = NULL;
- state->id = current_thread;
- SetCurrentThreadState(state);
- }
- return state;
-}
-
-
-void ThreadInterrupter::UpdateStateObject(ThreadInterruptCallback callback,
- void* data) {
- InterruptableThreadState* state = CurrentThreadState();
- ThreadId current_thread = OSThread::GetCurrentThreadId();
- ASSERT(state != NULL);
- ASSERT(OSThread::Compare(state->id, OSThread::GetCurrentThreadId()));
- SetCurrentThreadState(NULL);
- // It is now safe to modify the state object. If an interrupt occurs,
- // the current thread state will be NULL.
- state->callback = callback;
- state->data = data;
- SetCurrentThreadState(state);
- if (FLAG_trace_thread_interrupter) {
- intptr_t tid = OSThread::ThreadIdToIntPtr(current_thread);
- if (callback == NULL) {
- OS::Print("ThreadInterrupter Cleared %p\n", reinterpret_cast<void*>(tid));
- } else {
- OS::Print("ThreadInterrupter Updated %p\n", reinterpret_cast<void*>(tid));
- }
- }
-}
-
-
-InterruptableThreadState* ThreadInterrupter::GetCurrentThreadState() {
- return _EnsureThreadStateCreated();
-}
-
-
-InterruptableThreadState* ThreadInterrupter::CurrentThreadState() {
- Thread* thread = Thread::Current();
- return (thread == NULL) ? NULL : thread->thread_state();
-}
-
-
-void ThreadInterrupter::SetCurrentThreadState(InterruptableThreadState* state) {
- Thread::Current()->set_thread_state(state);
-}
-
void ThreadInterruptNoOp(const InterruptedThreadState& state, void* data) {
// NoOp.

Powered by Google App Engine
This is Rietveld 408576698