![]() |
NeoPZ
|
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... | |
Implements semaphore to threads. Utility.
Definition at line 15 of file TPZSemaphore.h.
| 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 | ( | void | ) |
Default destructor.
Definition at line 23 of file TPZSemaphore.cpp.
References fCond, fMutex, PZ_PTHREAD_COND_DESTROY, and PZ_PTHREAD_MUTEX_DESTROY.
| 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.
| void TPZSemaphore::Post | ( | ) |
Definition at line 82 of file TPZSemaphore.cpp.
References fCond, fCounter, fMutex, LOGPZ_DEBUG, PZ_PTHREAD_COND_SIGNAL, PZ_PTHREAD_MUTEX_LOCK, and PZ_PTHREAD_MUTEX_UNLOCK.
Referenced by TPZDohrAssembleList< TVar >::AddItem(), TPZStructMatrixOR::ThreadData::ComputedElementMatrix(), TPZPairStructMatrix::ThreadData::ComputedElementMatrix(), tht::SemaphorePost(), TPZStructMatrixOR::ThreadData::ThreadWork(), and TPZPairStructMatrix::ThreadData::ThreadWork().
| void TPZSemaphore::Wait | ( | ) |
Definition at line 36 of file TPZSemaphore.cpp.
References fCond, fCounter, fMutex, LOGPZ_DEBUG, PZ_PTHREAD_COND_WAIT, PZ_PTHREAD_MUTEX_LOCK, and PZ_PTHREAD_MUTEX_UNLOCK.
Referenced by TPZDohrAssembleList< TVar >::Assemble(), tht::SemaphoreWait(), TPZStructMatrixOR::ThreadData::ThreadAssembly(), TPZPairStructMatrix::ThreadData::ThreadAssembly1(), and TPZPairStructMatrix::ThreadData::ThreadAssembly2().
|
private |
Condition for the thread must to be waiting.
Definition at line 23 of file TPZSemaphore.h.
Referenced by Post(), TPZSemaphore(), Wait(), and ~TPZSemaphore().
|
private |
Counter of the times the semaphore is locked.
Definition at line 19 of file TPZSemaphore.h.
Referenced by Post(), TPZSemaphore(), and Wait().
|
private |
Mutex for the thread.
Definition at line 21 of file TPZSemaphore.h.
Referenced by Post(), TPZSemaphore(), Wait(), and ~TPZSemaphore().
1.8.13