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

Unified Diff: runtime/vm/thread.cc

Issue 1412733008: Switch profiler from isolates to threads (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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.cc
diff --git a/runtime/vm/thread.cc b/runtime/vm/thread.cc
index a2af102a7ebc4736a645e2fd800e2c5b4ef5aa8a..c4bfd365c5351a6608cf78fc34500efcf6a2fd83 100644
--- a/runtime/vm/thread.cc
+++ b/runtime/vm/thread.cc
@@ -66,6 +66,9 @@ void Thread::AddThreadToList(Thread* thread) {
// Insert at head of list.
thread->thread_list_next_ = thread_list_head_;
thread_list_head_ = thread;
+
+ // Make sure the thread interrupter is awake.
+ ThreadInterrupter::WakeUp();
}
@@ -180,6 +183,7 @@ Thread::Thread(bool init_vm_constants)
: id_(OSThread::GetCurrentThreadId()),
thread_interrupt_callback_(NULL),
thread_interrupt_data_(NULL),
+ thread_interrupt_disabled_(0),
isolate_(NULL),
heap_(NULL),
timeline_block_(NULL),
@@ -452,6 +456,29 @@ void Thread::VisitObjectPointers(ObjectPointerVisitor* visitor) {
}
+void Thread::DisableThreadInterrupts() {
+ ASSERT(Thread::Current() == this);
+ AtomicOperations::FetchAndIncrement(&thread_interrupt_disabled_);
+}
+
+
+void Thread::EnableThreadInterrupts() {
+ ASSERT(Thread::Current() == this);
+ uintptr_t old =
+ AtomicOperations::FetchAndDecrement(&thread_interrupt_disabled_);
+ if (old == 1) {
+ // We just decremented from 1 to 0.
+ // Make sure the thread interrupter is awake.
+ ThreadInterrupter::WakeUp();
+ }
+}
+
+
+bool Thread::ThreadInterruptsEnabled() {
+ return AtomicOperations::LoadRelaxed(&thread_interrupt_disabled_) == 0;
+}
+
+
void Thread::SetThreadInterrupter(ThreadInterruptCallback callback,
void* data) {
ASSERT(Thread::Current() == this);

Powered by Google App Engine
This is Rietveld 408576698