Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
AsyncNotifiableBlock::QueuedBarrier Class Reference

Notifiable class that can act as a BarrierNotifiable but also be enlisted in a queue. More...

Inheritance diagram for AsyncNotifiableBlock::QueuedBarrier:
BarrierNotifiable QMember Notifiable Atomic Destructable

Public Member Functions

void notify () override
 Notification implementation.
 
void check_one_count ()
 Checks that there is exactly one count in here.
 
- Public Member Functions inherited from BarrierNotifiable
 BarrierNotifiable ()
 Constructs a barrier notifiable that is done.
 
 BarrierNotifiable (Notifiable *done)
 Constructs a barrier notifiable that is live.
 
BarrierNotifiablereset (Notifiable *done)
 Resets the barrier. Returns &*this. Asserts that is_done().
 
BarrierNotifiablenew_child ()
 Call this for each child task.
 
void maybe_done ()
 When there are no more child tasks to add, call maybe_done().
 
bool is_done ()
 
bool abort_if_almost_done ()
 Checks if there is exactly one outstanding notification left in the barrier.
 
- Public Member Functions inherited from QMember
void init ()
 Initiailize a QMember, in place of a public placement construction.
 

Additional Inherited Members

- Protected Member Functions inherited from Atomic
void lock ()
 
void unlock ()
 
- Protected Member Functions inherited from QMember
 QMember ()
 Constructor.
 
 ~QMember ()
 Destructor.
 
- Protected Attributes inherited from BarrierNotifiable
unsigned count_
 How many outstanding notifications we are still waiting for.
 
Notifiabledone_
 Notifiable to call when the barrier reaches zero.
 
- Protected Attributes inherited from QMember
QMembernext
 pointer to the next member in the queue
 

Detailed Description

Notifiable class that can act as a BarrierNotifiable but also be enlisted in a queue.

Definition at line 58 of file AsyncNotifiableBlock.hxx.

Member Function Documentation

◆ check_one_count()

void AsyncNotifiableBlock::QueuedBarrier::check_one_count ( )
inline

Checks that there is exactly one count in here.

Definition at line 86 of file AsyncNotifiableBlock.hxx.

◆ notify()

void AsyncNotifiableBlock::QueuedBarrier::notify ( )
inlineoverridevirtual

Notification implementation.

Theory of operation: If this was the last notification (count goes from 1 to 0), we take the done_ pointer, cast it to the owning AsyncNotifiableBlock, and release outselves into the queue there. We keep the count at 1 at all times, which ensures that the done_ pointer remains pointing to the owner AsyncNotifiableBlock.

Reimplemented from BarrierNotifiable.

Definition at line 68 of file AsyncNotifiableBlock.hxx.


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