VAPOR3 3.9.4
EasyThreads.h
Go to the documentation of this file.
1
2#ifndef _EasyThreads_h_
3#define _EasyThreads_h_
4
5#include <vector>
6
7#ifndef WIN32
8 #include <pthread.h>
9#else
10 #include <windows.h>
11 #include <process.h>
12#endif
13#include "MyBase.h"
14
15namespace Wasp {
16
18public:
19 EasyThreads(int nthreads);
21 int ParRun(void *(*start)(void *), std::vector<void *> arg);
22 int ParRun(void *(*start)(void *), void **arg);
23 int Barrier();
24 int MutexLock();
26 static void Decompose(int n, int size, int rank, int *offset, int *length);
27 static int NProc();
28 int GetNumThreads() const { return (nthreads_c); }
29
30private:
31#ifndef WIN32
32
33 int nthreads_c;
34 pthread_t * threads_c;
35 pthread_attr_t attr_c;
36 pthread_cond_t cond_c;
37 pthread_mutex_t barrier_lock_c;
38 pthread_mutex_t mutex_lock_c;
39 int block_c;
40 int count_c; // counters for barrier
41
42#else
43
44 bool initialized_c;
45 int nblocked_c;
46 int nthreads_c;
47 HANDLE *threads_c;
48 HANDLE *mutices_c;
49 HANDLE *bMutices_c;
50 HANDLE mutex_c;
51 HANDLE bMutex_c;
52
53#endif
54};
55
56}; // namespace Wasp
57
58#endif
static int NProc()
int GetNumThreads() const
Definition: EasyThreads.h:28
int ParRun(void *(*start)(void *), void **arg)
EasyThreads(int nthreads)
int ParRun(void *(*start)(void *), std::vector< void * > arg)
static void Decompose(int n, int size, int rank, int *offset, int *length)
Wasp base class.
Definition: MyBase.h:67
#define COMMON_API
Definition: common.h:72
Definition: CFuncs.h:31