COMPASS  5.4.4
End-to-end AO simulation tool using GPU acceleration
carma_multithread.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 // This file is part of COMPASS <https://anr-compass.github.io/compass/>
3 //
4 // Copyright (C) 2011-2023 COMPASS Team <https://github.com/ANR-COMPASS>
5 // All rights reserved.
6 
7 // -----------------------------------------------------------------------------
8 
15 
16 #ifndef CARMA_MULTITHREAD_H
17 #define CARMA_MULTITHREAD_H
18 
19 // Simple portable thread library.
20 
21 // POSIX threads.
22 #include <pthread.h>
23 
24 typedef pthread_t carma_thread;
25 typedef void *(*carma_routine)(void *);
26 
27 #define CARMAT_THREADPROC void *
28 #define CARMAT_THREADEND return 0
29 
31  pthread_mutex_t mutex;
32  pthread_cond_t conditionVariable;
34  int count;
35 };
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 // Create thread
43 // Wait for thread to finish
45 // Destroy thread
47 // Wait for multiple threads
48 void carma_wait4thread(const carma_thread *threads, int num);
49 // Create barrier.
51 // Increment barrier. (excution continues)
53 // Wait for barrier release.
55 // Destory barrier
57 
58 #ifdef __cplusplus
59 } // extern "C"
60 #endif
61 
62 #endif // CARMA_MULTITHREAD_H
void carma_destroy_thread(carma_thread thread)
CarmaThreadBarrier carma_create_barrier(int releaseCount)
pthread_t carma_thread
void carma_destroy_barrier(CarmaThreadBarrier *barrier)
void carma_increment_barrier(CarmaThreadBarrier *barrier)
void carma_wait4thread(const carma_thread *threads, int num)
carma_thread carma_start_thread(carma_routine func, void *data)
void carma_wait4barrier(CarmaThreadBarrier *barrier)
void carma_end_thread(carma_thread thread)
void *(* carma_routine)(void *)
pthread_mutex_t mutex
pthread_cond_t conditionVariable