join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::SharedSemaphore Class Reference

class used to protect shared data from being simultaneously accessed by multiple process via a shared memory. More...

#include <semaphore.hpp>

Public Member Functions

 SharedSemaphore (size_t value=0)
 create instance.
 
 SharedSemaphore (const SharedSemaphore &other)=delete
 copy constructor.
 
SharedSemaphoreoperator= (const SharedSemaphore &other)=delete
 copy assignment operator.
 
 ~SharedSemaphore () noexcept
 destroy instance.
 
void post () noexcept
 increments the internal counter and unblocks acquirers.
 
void wait () noexcept
 decrements the internal counter or blocks until it can
 
bool tryWait () noexcept
 tries to decrement the internal counter without blocking.
 
template<class Rep , class Period >
bool timedWait (std::chrono::duration< Rep, Period > timeout)
 tries to decrement the internal counter, blocking for up to a duration time.
 
int value () noexcept
 get semaphore value.
 

Detailed Description

class used to protect shared data from being simultaneously accessed by multiple process via a shared memory.

Constructor & Destructor Documentation

◆ SharedSemaphore() [1/2]

SharedSemaphore::SharedSemaphore ( size_t value = 0)

create instance.

Parameters
valueintial value.

◆ SharedSemaphore() [2/2]

join::SharedSemaphore::SharedSemaphore ( const SharedSemaphore & other)
delete

copy constructor.

Parameters
otherother object to copy.

◆ ~SharedSemaphore()

SharedSemaphore::~SharedSemaphore ( )
noexcept

destroy instance.

Member Function Documentation

◆ operator=()

SharedSemaphore & join::SharedSemaphore::operator= ( const SharedSemaphore & other)
delete

copy assignment operator.

Parameters
otherother object to assign.
Returns
assigned object.

◆ post()

void SharedSemaphore::post ( )
noexcept

increments the internal counter and unblocks acquirers.

◆ timedWait()

template<class Rep , class Period >
bool join::SharedSemaphore::timedWait ( std::chrono::duration< Rep, Period > timeout)
inline

tries to decrement the internal counter, blocking for up to a duration time.

Parameters
timeouttimeout.
Returns
true on success, false otherwise.

◆ tryWait()

bool SharedSemaphore::tryWait ( )
noexcept

tries to decrement the internal counter without blocking.

Returns
true on success, false otherwise.

◆ value()

int SharedSemaphore::value ( )
noexcept

get semaphore value.

Returns
-1 on error, semaphore value otherwise.

◆ wait()

void SharedSemaphore::wait ( )
noexcept

decrements the internal counter or blocks until it can


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