Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::system::Semaphore Class Referencefinal

Named Semaphore. More...

#include <Semaphore.h>

Public Types

using Ptr = std::unique_ptr<Semaphore>
 

Public Member Functions

 ~Semaphore ()
 
bool lock ()
 Block and wait until resource is acquired.
 
bool unlock ()
 Release the current resource.
 
bool tryLock (std::chrono::milliseconds ms)
 

Static Public Member Functions

static Semaphore::Ptr create (std::string name, uint32_t initial_count=1)
 

Private Member Functions

 Semaphore ()=default
 

Private Attributes

std::string sem_name {}
 
sem_t * semaphore {}
 

Detailed Description

Named Semaphore.

Member Typedef Documentation

◆ Ptr

using sese::system::Semaphore::Ptr = std::unique_ptr<Semaphore>

Constructor & Destructor Documentation

◆ ~Semaphore()

Semaphore::~Semaphore ( )

References sem_name, and semaphore.

◆ Semaphore()

sese::system::Semaphore::Semaphore ( )
privatedefault

Member Function Documentation

◆ create()

Semaphore::Ptr Semaphore::create ( std::string name,
uint32_t initial_count = 1 )
static

Create a named semaphore

Parameters
nameName
initial_countInitial count, default is 1 behaving like a mutex
Return values
nullptrCreation failed

References MAKE_UNIQUE_PRIVATE.

Referenced by sese::system::IPCChannel::create(), and sese::system::IPCChannel::use().

◆ lock()

bool Semaphore::lock ( )

Block and wait until resource is acquired.

References semaphore.

◆ tryLock()

bool Semaphore::tryLock ( std::chrono::milliseconds ms)

Try to acquire resource within a certain time

Parameters
msWaiting time in milliseconds, invalid on APPLE platforms
Returns
Whether acquisition is successful

References semaphore.

◆ unlock()

bool Semaphore::unlock ( )

Release the current resource.

References semaphore.

Member Data Documentation

◆ sem_name

std::string sese::system::Semaphore::sem_name {}
private

Referenced by ~Semaphore().

◆ semaphore

sem_t* sese::system::Semaphore::semaphore {}
private

Referenced by lock(), tryLock(), unlock(), and ~Semaphore().


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