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

Named Semaphore. More...

#include <Semaphore.h>

Classes

class  Impl
 

Public Types

using Ptr = std::unique_ptr<Semaphore>
 

Public Member Functions

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

Static Public Member Functions

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

Private Member Functions

 Semaphore (std::unique_ptr< Impl > impl)
 

Private Attributes

std::unique_ptr< Implimpl
 

Detailed Description

Named Semaphore.

Member Typedef Documentation

◆ Ptr

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

Constructor & Destructor Documentation

◆ ~Semaphore()

Semaphore::~Semaphore ( )

◆ Semaphore()

Semaphore::Semaphore ( std::unique_ptr< Impl > impl)
explicitprivate

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 sese::system::Semaphore::Impl::create(), impl, and MAKE_UNIQUE_PRIVATE.

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

◆ lock()

bool Semaphore::lock ( ) const

Block and wait until resource is acquired.

References impl.

◆ tryLock()

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

Try to acquire resource within a certain time

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

References impl.

◆ unlock()

bool Semaphore::unlock ( ) const

Release the current resource.

References impl.

Member Data Documentation

◆ impl

std::unique_ptr<Impl> sese::system::Semaphore::impl
private

Referenced by create(), lock(), tryLock(), and unlock().


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