Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
SemaphoreNotifiableBlock Class Reference

A block of BarrierNotifiable objects, with a synchronous allocation call. More...

#include <SemaphoreNotifiableBlock.hxx>

Inheritance diagram for SemaphoreNotifiableBlock:
Notifiable Atomic

Public Member Functions

 SemaphoreNotifiableBlock (unsigned num_parallelism)
 constructor.
 
BarrierNotifiableacquire ()
 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.
 
BarrierNotifiablebarriers_
 The raw pointer to the block of barriernotifiables.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SemaphoreNotifiableBlock()

SemaphoreNotifiableBlock::SemaphoreNotifiableBlock ( unsigned  num_parallelism)
inline

constructor.

Parameters
num_parallelismtells how many BarrierNotifiables we should have and hand out to threads requesting them.

Definition at line 50 of file SemaphoreNotifiableBlock.hxx.

◆ ~SemaphoreNotifiableBlock()

SemaphoreNotifiableBlock::~SemaphoreNotifiableBlock ( )
inline

Definition at line 57 of file SemaphoreNotifiableBlock.hxx.

Member Function Documentation

◆ acquire()

BarrierNotifiable * SemaphoreNotifiableBlock::acquire ( )
inline

Gets a barrier notifiable.

May block the current thread if there isn't one ready.

Returns
a fresh BarrierNotifiable.

Definition at line 64 of file SemaphoreNotifiableBlock.hxx.

◆ notify()

void SemaphoreNotifiableBlock::notify ( )
inlineoverridevirtual

Internal: notifies that a barrier has been returned.

Implements Notifiable.

Definition at line 76 of file SemaphoreNotifiableBlock.hxx.

Member Data Documentation

◆ barriers_

BarrierNotifiable* SemaphoreNotifiableBlock::barriers_
private

The raw pointer to the block of barriernotifiables.

Definition at line 95 of file SemaphoreNotifiableBlock.hxx.

◆ count_

unsigned SemaphoreNotifiableBlock::count_
private

How many barriers did we allocate in total?

Definition at line 91 of file SemaphoreNotifiableBlock.hxx.

◆ sem_

OSSem SemaphoreNotifiableBlock::sem_
private

Semaphore holding free barriers.

Definition at line 93 of file SemaphoreNotifiableBlock.hxx.


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