|
Open Model Railroad Network (OpenMRN)
|
A block of BarrierNotifiable objects, with a synchronous allocation call. More...
#include <SemaphoreNotifiableBlock.hxx>
Public Member Functions | |
| SemaphoreNotifiableBlock (unsigned num_parallelism) | |
| constructor. | |
| BarrierNotifiable * | acquire () |
| Gets a barrier notifiable. | |
| void | notify () override |
| Internal: notifies that a barrier has been returned. | |
Private Member Functions | |
| DISALLOW_COPY_AND_ASSIGN (SemaphoreNotifiableBlock) | |
Private Member Functions inherited from Atomic | |
| void | lock () |
| void | unlock () |
Private Attributes | |
| unsigned | count_ |
| How many barriers did we allocate in total? | |
| OSSem | sem_ |
| Semaphore holding free barriers. | |
| BarrierNotifiable * | barriers_ |
| The raw pointer to the block of barriernotifiables. | |
A block of BarrierNotifiable objects, with a synchronous allocation call.
Caller threads can block on allocating a new entry, and then get back a fresh BarrierNotifiable, which, upon being released will automatically be reallocated to a waiting thread, if any.
Definition at line 45 of file SemaphoreNotifiableBlock.hxx.
|
inline |
constructor.
| num_parallelism | tells how many BarrierNotifiables we should have and hand out to threads requesting them. |
Definition at line 50 of file SemaphoreNotifiableBlock.hxx.
|
inline |
Definition at line 57 of file SemaphoreNotifiableBlock.hxx.
|
inline |
Gets a barrier notifiable.
May block the current thread if there isn't one ready.
Definition at line 64 of file SemaphoreNotifiableBlock.hxx.
|
inlineoverridevirtual |
Internal: notifies that a barrier has been returned.
Implements Notifiable.
Definition at line 76 of file SemaphoreNotifiableBlock.hxx.
|
private |
The raw pointer to the block of barriernotifiables.
Definition at line 95 of file SemaphoreNotifiableBlock.hxx.
|
private |
How many barriers did we allocate in total?
Definition at line 91 of file SemaphoreNotifiableBlock.hxx.
|
private |
Semaphore holding free barriers.
Definition at line 93 of file SemaphoreNotifiableBlock.hxx.