Flutter Engine
The Flutter Engine
Static Public Member Functions | Friends | List of all members
dart::ThreadInterrupter Class Reference

#include <thread_interrupter.h>

Inheritance diagram for dart::ThreadInterrupter:
dart::AllStatic

Static Public Member Functions

static void Init ()
 
static void Startup ()
 
static void Cleanup ()
 
static void SetInterruptPeriod (intptr_t period)
 
static void WakeUp ()
 
static void InterruptThread (OSThread *thread)
 
static void * PrepareCurrentThread ()
 
static void CleanupCurrentThreadState (void *state)
 

Friends

class ThreadInterrupterVisitIsolates
 

Detailed Description

Definition at line 23 of file thread_interrupter.h.

Member Function Documentation

◆ Cleanup()

void dart::ThreadInterrupter::Cleanup ( )
static

Definition at line 83 of file thread_interrupter.cc.

83 {
84 {
85 MonitorLocker shutdown_ml(monitor_);
86 if (shutdown_) {
87 // Already shutdown.
88 return;
89 }
90 shutdown_ = true;
91 // Notify.
92 shutdown_ml.Notify();
93 ASSERT(initialized_);
94 if (FLAG_trace_thread_interrupter) {
95 OS::PrintErr("ThreadInterrupter shutting down.\n");
96 }
97 }
98
99 // Join the thread.
100 ASSERT(interrupter_thread_id_ != OSThread::kInvalidThreadJoinId);
101 OSThread::Join(interrupter_thread_id_);
102 interrupter_thread_id_ = OSThread::kInvalidThreadJoinId;
103 initialized_ = false;
104
105 if (FLAG_trace_thread_interrupter) {
106 OS::PrintErr("ThreadInterrupter shut down.\n");
107 }
108}
static void Join(ThreadJoinId id)
static const ThreadJoinId kInvalidThreadJoinId
Definition: os_thread.h:249
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
#define ASSERT(E)

◆ CleanupCurrentThreadState()

void dart::ThreadInterrupter::CleanupCurrentThreadState ( void *  state)
static

Definition at line 238 of file thread_interrupter.cc.

238{}

◆ Init()

void dart::ThreadInterrupter::Init ( )
static

Definition at line 54 of file thread_interrupter.cc.

54 {
55 ASSERT(!initialized_);
56 if (monitor_ == nullptr) {
57 monitor_ = new Monitor();
58 }
59 ASSERT(monitor_ != nullptr);
60 initialized_ = true;
61 shutdown_ = false;
62}

◆ InterruptThread()

static void dart::ThreadInterrupter::InterruptThread ( OSThread thread)
static

◆ PrepareCurrentThread()

void * dart::ThreadInterrupter::PrepareCurrentThread ( )
static

Definition at line 234 of file thread_interrupter.cc.

234 {
235 return nullptr;
236}

◆ SetInterruptPeriod()

void dart::ThreadInterrupter::SetInterruptPeriod ( intptr_t  period)
static

Definition at line 111 of file thread_interrupter.cc.

111 {
112 if (!initialized_) {
113 // Profiler may not be enabled.
114 return;
115 }
116 MonitorLocker ml(monitor_);
117 if (shutdown_) {
118 return;
119 }
120 ASSERT(initialized_);
121 ASSERT(period > 0);
122 interrupt_period_ = period;
123}

◆ Startup()

void dart::ThreadInterrupter::Startup ( )
static

Definition at line 64 of file thread_interrupter.cc.

64 {
65 ASSERT(initialized_);
66 if (FLAG_trace_thread_interrupter) {
67 OS::PrintErr("ThreadInterrupter starting up.\n");
68 }
69 ASSERT(interrupter_thread_id_ == OSThread::kInvalidThreadJoinId);
70 {
71 MonitorLocker startup_ml(monitor_);
72 OSThread::Start("Dart Profiler ThreadInterrupter", ThreadMain, 0);
73 while (!thread_running_) {
74 startup_ml.Wait();
75 }
76 }
77 ASSERT(interrupter_thread_id_ != OSThread::kInvalidThreadJoinId);
78 if (FLAG_trace_thread_interrupter) {
79 OS::PrintErr("ThreadInterrupter running.\n");
80 }
81}
static int Start(const char *name, ThreadStartFunction function, uword parameter)

◆ WakeUp()

void dart::ThreadInterrupter::WakeUp ( )
static

Definition at line 125 of file thread_interrupter.cc.

125 {
126 if (monitor_ == nullptr) {
127 // Early call.
128 return;
129 }
130 {
131 MonitorLocker ml(monitor_);
132 if (shutdown_) {
133 // Late call
134 return;
135 }
136 if (!initialized_) {
137 // Early call.
138 return;
139 }
140 woken_up_ = true;
141 if (!InDeepSleep()) {
142 // No need to notify, regularly waking up.
143 return;
144 }
145 // Notify the interrupter to wake it from its deep sleep.
146 ml.Notify();
147 }
148}

Friends And Related Function Documentation

◆ ThreadInterrupterVisitIsolates

friend class ThreadInterrupterVisitIsolates
friend

Definition at line 67 of file thread_interrupter.h.


The documentation for this class was generated from the following files: