NeoPZ
TPZThreadTools.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 #ifndef TPZThreadToolsH
3 #define TPZThreadToolsH
4 
5 #define using_pthread
6 #ifdef using_pthread
7  #include "pthread.h"
8  //#include "semaphore.h" does not work in MACOS
9  #include "TPZSemaphore.h"
10 #endif
11 #ifdef WINDOWS_THREADS
12 #ifndef NOMINMAX
13 #define NOMINMAX // Preventing the redefinition of min and max as macros
14 #endif
15  #include <windows.h>
16 #endif
17 #ifdef EMBARCADERO_THREADS
18  #include "System.hpp"
19  #include "SyncObjs.hpp"
20  #include "tpzautopointer.h"
21  #include "TSWXEmbarcaderoThread.h"
22 #endif
23 
24 
25 #ifdef using_pthread
26 typedef pthread_mutex_t pz_critical_section_t;
27 typedef pthread_mutex_t pz_mutex_t;
29 typedef pthread_t pz_thread_t;
30 #endif
31 #ifdef WINDOWS_THREADS
32 typedef CRITICAL_SECTION pz_critical_section_t;
33 typedef HANDLE pz_mutex_t;
34 typedef HANDLE pz_semaphore_t;
35 typedef HANDLE pz_thread_t;
36 #endif
37 #ifdef EMBARCADERO_THREADS
42 #endif
43 
44 // namespace tht means "ThreadTools"
45 namespace tht{
46 
49 
51 
53 
55 
58 
59  void DeleteMutex(pz_mutex_t & m);
60 
61  void MutexLock(pz_mutex_t & m);
62 
63  void MutexUnlock(pz_mutex_t & m);
64 
67 
69 
70  void SemaphorePost( pz_semaphore_t & s );
71 
72  void SemaphoreWait( pz_semaphore_t & s );
73 
75  void CreateThread( pz_thread_t & thread, void* (*function)(void* param), void* data);
76 
77  void ThreadWaitFor(pz_thread_t & thread);
78 
79 }
80 #endif
Contains declaration of the TPZSemaphore class which implements semaphore to threads.
void DeleteSemaphore(pz_semaphore_t &s)
Implements semaphore to threads. Utility.
Definition: TPZSemaphore.h:15
int InitializeSemaphore(pz_semaphore_t &s)
Semaforos.
pthread_mutex_t pz_critical_section_t
void MutexUnlock(pz_mutex_t &m)
void LeaveCriticalSection(pz_critical_section_t &cs)
pthread_mutex_t pz_mutex_t
void EnterCriticalSection(pz_critical_section_t &cs)
void CreateThread(pz_thread_t &thread, void *(*function)(void *param), void *data)
Threads.
void InitializeCriticalSection(pz_critical_section_t &cs)
Critical sections.
void ThreadWaitFor(pz_thread_t &thread)
Contains declaration of the TPZAutoPointer class which has Increment and Decrement actions are mutexe...
void MutexLock(pz_mutex_t &m)
void SemaphoreWait(pz_semaphore_t &s)
void SemaphorePost(pz_semaphore_t &s)
pthread_t pz_thread_t
TPZSemaphore pz_semaphore_t
clarg::argString m("-m", "input matrix file name (text format)", "matrix.txt")
void DeleteMutex(pz_mutex_t &m)
namespace tht means "ThreadTools"
void InitializeMutex(pz_mutex_t &m)
Mutexes.
void DeleteCriticalSection(pz_critical_section_t &cs)
This class implements a reference counter mechanism to administer a dynamically allocated object...