Flutter Engine
fml::PlatformSemaphore Class Reference

Public Member Functions

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

Detailed Description

Definition at line 102 of file semaphore.cc.

Constructor & Destructor Documentation

◆ PlatformSemaphore()

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

Definition at line 104 of file semaphore.cc.

105  : valid_(::sem_init(&sem_, 0 /* not shared */, count) == 0) {}

◆ ~PlatformSemaphore()

fml::PlatformSemaphore::~PlatformSemaphore ( )
inline

Definition at line 107 of file semaphore.cc.

References FML_DCHECK.

107  {
108  if (valid_) {
109  int result = ::sem_destroy(&sem_);
110  // Can only be EINVAL which should not be possible since we checked for
111  // validity.
112  FML_DCHECK(result == 0);
113  }
114  }
#define FML_DCHECK(condition)
Definition: logging.h:86

Member Function Documentation

◆ IsValid()

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

Definition at line 116 of file semaphore.cc.

116 { return valid_; }

◆ Signal()

void fml::PlatformSemaphore::Signal ( )
inline

Definition at line 126 of file semaphore.cc.

References FML_DISALLOW_COPY_AND_ASSIGN.

126  {
127  if (!valid_) {
128  return;
129  }
130 
131  ::sem_post(&sem_);
132 
133  return;
134  }

◆ TryWait()

bool fml::PlatformSemaphore::TryWait ( )
inline

Definition at line 118 of file semaphore.cc.

References FML_HANDLE_EINTR.

118  {
119  if (!valid_) {
120  return false;
121  }
122 
123  return FML_HANDLE_EINTR(::sem_trywait(&sem_)) == 0;
124  }
#define FML_HANDLE_EINTR(x)
Definition: eintr_wrapper.h:33

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