BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
Semaphore Class Reference

Public Member Functions

 Semaphore (unsigned int resource_count=0)
void acquire ()
 Acquires a resource from the semaphore.
void release ()
 Releases a resource from the semaphore.

Private Attributes

mutex mutex_
condition_variable condition_
unsigned int count_

Detailed Description

Definition at line 76 of file nica-scheduler.cpp.

Constructor & Destructor Documentation

◆ Semaphore()

Semaphore::Semaphore ( unsigned int resource_count = 0)
inline

Definition at line 79 of file nica-scheduler.cpp.

References count_.

Member Function Documentation

◆ acquire()

void Semaphore::acquire ( )
inline

Decrements the internal resource count. If the count is zero, the calling thread will block until another thread releases a resource by calling release().

Definition at line 90 of file nica-scheduler.cpp.

References condition_, count_, and mutex_.

◆ release()

void Semaphore::release ( )
inline

Increments the internal resource count. If a thread is waiting for a resource to be released, it will be notified.

Definition at line 103 of file nica-scheduler.cpp.

References condition_, count_, and mutex_.

Member Data Documentation

◆ condition_

condition_variable Semaphore::condition_
private

Definition at line 112 of file nica-scheduler.cpp.

Referenced by acquire(), and release().

◆ count_

unsigned int Semaphore::count_
private

Definition at line 113 of file nica-scheduler.cpp.

Referenced by Semaphore(), acquire(), and release().

◆ mutex_

mutex Semaphore::mutex_
private

Definition at line 111 of file nica-scheduler.cpp.

Referenced by acquire(), and release().


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