Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dart::MonitorLocker Class Reference

#include <lockers.h>

Inheritance diagram for dart::MonitorLocker:
dart::ValueObject

Public Member Functions

 MonitorLocker (Monitor *monitor, bool no_safepoint_scope=true)
 
virtual ~MonitorLocker ()
 
void Enter () const
 
void Exit () const
 
Monitor::WaitResult Wait (int64_t millis=Monitor::kNoTimeout)
 
Monitor::WaitResult WaitWithSafepointCheck (Thread *thread, int64_t millis=Monitor::kNoTimeout)
 
Monitor::WaitResult WaitMicros (int64_t micros=Monitor::kNoTimeout)
 
void Notify ()
 
void NotifyAll ()
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Detailed Description

Definition at line 128 of file lockers.h.

Constructor & Destructor Documentation

◆ MonitorLocker()

dart::MonitorLocker::MonitorLocker ( Monitor monitor,
bool  no_safepoint_scope = true 
)
inlineexplicit

Definition at line 130 of file lockers.h.

131 : monitor_(monitor), no_safepoint_scope_(no_safepoint_scope) {
132 ASSERT(monitor != nullptr);
133#if defined(DEBUG)
134 if (no_safepoint_scope_) {
135 Thread* thread = Thread::Current();
136 if (thread != nullptr) {
137 thread->IncrementNoSafepointScopeDepth();
138 } else {
139 no_safepoint_scope_ = false;
140 }
141 }
142#endif
143 monitor_->Enter();
144 }
static Thread * Current()
Definition thread.h:361
#define ASSERT(E)

◆ ~MonitorLocker()

virtual dart::MonitorLocker::~MonitorLocker ( )
inlinevirtual

Definition at line 146 of file lockers.h.

146 {
147 monitor_->Exit();
148#if defined(DEBUG)
149 if (no_safepoint_scope_) {
151 }
152#endif
153 }
void DecrementNoSafepointScopeDepth()
Definition thread.h:720

Member Function Documentation

◆ Enter()

void dart::MonitorLocker::Enter ( ) const
inline

Definition at line 155 of file lockers.h.

155 {
156#if defined(DEBUG)
157 if (no_safepoint_scope_) {
159 }
160#endif
161 monitor_->Enter();
162 }
void IncrementNoSafepointScopeDepth()
Definition thread.h:713

◆ Exit()

void dart::MonitorLocker::Exit ( ) const
inline

Definition at line 163 of file lockers.h.

163 {
164 monitor_->Exit();
165#if defined(DEBUG)
166 if (no_safepoint_scope_) {
168 }
169#endif
170 }

◆ Notify()

void dart::MonitorLocker::Notify ( )
inline

Definition at line 184 of file lockers.h.

184{ monitor_->Notify(); }

◆ NotifyAll()

void dart::MonitorLocker::NotifyAll ( )
inline

Definition at line 186 of file lockers.h.

186{ monitor_->NotifyAll(); }

◆ Wait()

Monitor::WaitResult dart::MonitorLocker::Wait ( int64_t  millis = Monitor::kNoTimeout)
inline

Definition at line 172 of file lockers.h.

172 {
173 return monitor_->Wait(millis);
174 }

◆ WaitMicros()

Monitor::WaitResult dart::MonitorLocker::WaitMicros ( int64_t  micros = Monitor::kNoTimeout)
inline

Definition at line 180 of file lockers.h.

180 {
181 return monitor_->WaitMicros(micros);
182 }

◆ WaitWithSafepointCheck()

Monitor::WaitResult dart::MonitorLocker::WaitWithSafepointCheck ( Thread thread,
int64_t  millis = Monitor::kNoTimeout 
)

Definition at line 12 of file lockers.cc.

13 {
14 ASSERT(thread == Thread::Current());
15 ASSERT(thread->execution_state() == Thread::kThreadInVM);
16#if defined(DEBUG)
17 if (no_safepoint_scope_) {
18 thread->DecrementNoSafepointScopeDepth();
19 }
20#endif
21 thread->set_execution_state(Thread::kThreadInBlockedState);
22 thread->EnterSafepoint();
23 Monitor::WaitResult result = monitor_->Wait(millis);
24 // First try a fast update of the thread state to indicate it is not at a
25 // safepoint anymore.
26 if (!thread->TryExitSafepoint()) {
27 // Fast update failed which means we could potentially be in the middle
28 // of a safepoint operation and need to block for it.
29 monitor_->Exit();
30 thread->ExitSafepointUsingLock();
31 monitor_->Enter();
32 }
33 thread->set_execution_state(Thread::kThreadInVM);
34#if defined(DEBUG)
35 if (no_safepoint_scope_) {
36 thread->IncrementNoSafepointScopeDepth();
37 }
38#endif
39 return result;
40}
@ kThreadInBlockedState
Definition thread.h:1024
GAsyncResult * result

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