NeoPZ
Public Member Functions | Private Attributes | List of all members
TPZSemaphore Class Reference

Implements semaphore to threads. Utility. More...

#include <TPZSemaphore.h>

Public Member Functions

 TPZSemaphore (void)
 Default constructor. More...
 
 ~TPZSemaphore (void)
 Default destructor. More...
 
 TPZSemaphore (int initCount)
 Constructor with initial number for the counter. More...
 
void Wait ()
 
void Post ()
 

Private Attributes

int fCounter
 Counter of the times the semaphore is locked. More...
 
pthread_mutex_t fMutex
 Mutex for the thread. More...
 
pthread_cond_t fCond
 Condition for the thread must to be waiting. More...
 

Detailed Description

Implements semaphore to threads. Utility.

Definition at line 15 of file TPZSemaphore.h.

Constructor & Destructor Documentation

◆ TPZSemaphore() [1/2]

TPZSemaphore::TPZSemaphore ( void  )

Default constructor.

Definition at line 16 of file TPZSemaphore.cpp.

References fCond, fCounter, fMutex, PZ_PTHREAD_COND_INIT, and PZ_PTHREAD_MUTEX_INIT.

◆ ~TPZSemaphore()

TPZSemaphore::~TPZSemaphore ( void  )

Default destructor.

Definition at line 23 of file TPZSemaphore.cpp.

References fCond, fMutex, PZ_PTHREAD_COND_DESTROY, and PZ_PTHREAD_MUTEX_DESTROY.

◆ TPZSemaphore() [2/2]

TPZSemaphore::TPZSemaphore ( int  initCount)

Constructor with initial number for the counter.

Definition at line 29 of file TPZSemaphore.cpp.

References fCond, fCounter, fMutex, PZ_PTHREAD_COND_INIT, and PZ_PTHREAD_MUTEX_INIT.

Member Function Documentation

◆ Post()

void TPZSemaphore::Post ( )

◆ Wait()

void TPZSemaphore::Wait ( )

Member Data Documentation

◆ fCond

pthread_cond_t TPZSemaphore::fCond
private

Condition for the thread must to be waiting.

Definition at line 23 of file TPZSemaphore.h.

Referenced by Post(), TPZSemaphore(), Wait(), and ~TPZSemaphore().

◆ fCounter

int TPZSemaphore::fCounter
private

Counter of the times the semaphore is locked.

Definition at line 19 of file TPZSemaphore.h.

Referenced by Post(), TPZSemaphore(), and Wait().

◆ fMutex

pthread_mutex_t TPZSemaphore::fMutex
private

Mutex for the thread.

Definition at line 21 of file TPZSemaphore.h.

Referenced by Post(), TPZSemaphore(), Wait(), and ~TPZSemaphore().


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