All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HSEP::Gate Class Reference

The Gate provides a queued synchronization access control. More...

#include <Gate.h>

+ Inheritance diagram for HSEP::Gate:

Public Member Functions

 Gate (bool pShared=false)
 Creates a "gate" synchronization primitive.
 
 ~Gate ()
 
void signal ()
 Send a "signal" for the first enqueued thread to pass the Gate.
 
void wait ()
 Waits until a signal is received and the calling thread is the first on the queued waiting list.
 

Detailed Description

The Gate provides a queued synchronization access control.

When more than one thread wait for a signal, the Gate will freeze each thread until a signal is sent to the Gate, and the first thread enqueued waiting for attention will pass, letting the others waiting for the next signal.

The Gate is different to a Dam, because in the Gate case, only one thread is letting to pass at a time, while in the Dam all them are let free in the same instant in time.

The C++11 condition_variable is not used because its definition is not complete (we need multi-process gates) so, the POSIX one takes its place.

Definition at line 48 of file Gate.h.

Constructor & Destructor Documentation

HSEP::Gate::Gate ( bool  pShared = false)

Creates a "gate" synchronization primitive.

Parameters
pSharedwhen true, the "gate" is created as a multi-process shared primitive, that can be used on Shared Memory areas.

Definition at line 32 of file Gate.cpp.

HSEP::Gate::~Gate ( )

Definition at line 60 of file Gate.cpp.

Member Function Documentation

void HSEP::Gate::signal ( )

Send a "signal" for the first enqueued thread to pass the Gate.

Definition at line 70 of file Gate.cpp.

void HSEP::Gate::wait ( )

Waits until a signal is received and the calling thread is the first on the queued waiting list.

The while(aWaiting) protects on the "Spurious awakening" behavior documented for POSIX standard (not an error, but designed to exist).

Definition at line 83 of file Gate.cpp.


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