Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
fml::PlatformSemaphore Class Reference

Public Member Functions

 PlatformSemaphore (uint32_t count)
 
 ~PlatformSemaphore ()
 
bool IsValid () const
 
bool Wait ()
 
bool TryWait ()
 
void Signal ()
 

Detailed Description

Definition at line 117 of file semaphore.cc.

Constructor & Destructor Documentation

◆ PlatformSemaphore()

fml::PlatformSemaphore::PlatformSemaphore ( uint32_t  count)
inlineexplicit

Definition at line 119 of file semaphore.cc.

120 : valid_(::sem_init(&sem_, 0 /* not shared */, count) == 0) {}
int count
Definition: FontMgrTest.cpp:50

◆ ~PlatformSemaphore()

fml::PlatformSemaphore::~PlatformSemaphore ( )
inline

Definition at line 122 of file semaphore.cc.

122 {
123 if (valid_) {
124 int result = ::sem_destroy(&sem_);
125 (void)result;
126 // Can only be EINVAL which should not be possible since we checked for
127 // validity.
128 FML_DCHECK(result == 0);
129 }
130 }
GAsyncResult * result
#define FML_DCHECK(condition)
Definition: logging.h:103

Member Function Documentation

◆ IsValid()

bool fml::PlatformSemaphore::IsValid ( ) const
inline

Definition at line 132 of file semaphore.cc.

132{ return valid_; }

◆ Signal()

void fml::PlatformSemaphore::Signal ( )
inline

Definition at line 150 of file semaphore.cc.

150 {
151 if (!valid_) {
152 return;
153 }
154
155 ::sem_post(&sem_);
156
157 return;
158 }

◆ TryWait()

bool fml::PlatformSemaphore::TryWait ( )
inline

Definition at line 142 of file semaphore.cc.

142 {
143 if (!valid_) {
144 return false;
145 }
146
147 return FML_HANDLE_EINTR(::sem_trywait(&sem_)) == 0;
148 }
#define FML_HANDLE_EINTR(x)
Definition: eintr_wrapper.h:20

◆ Wait()

bool fml::PlatformSemaphore::Wait ( )
inline

Definition at line 134 of file semaphore.cc.

134 {
135 if (!valid_) {
136 return false;
137 }
138
139 return FML_HANDLE_EINTR(::sem_wait(&sem_)) == 0;
140 }

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