ROOT-Sim core  3.0.0-rc.2
A General-Purpose Multi-threaded Parallel/Distributed Simulation Library
thread.h
Go to the documentation of this file.
1 
17 #pragma once
18 
19 #include <arch/platform.h>
20 
21 #if defined(__POSIX)
22 #include <pthread.h>
23 
24 #define THREAD_CALL_CONV
25 typedef void *thrd_ret_t;
26 typedef pthread_t thr_id_t;
27 
28 #define THREAD_RET_FAILURE ((void *)1)
29 #define THREAD_RET_SUCCESS ((void *)0)
30 
31 #elif defined(__WINDOWS)
32 
33 #define WIN32_LEAN_AND_MEAN
34 #include <windows.h>
35 #undef WIN32_LEAN_AND_MEAN
36 
37 #define THREAD_CALL_CONV WINAPI
38 typedef DWORD thrd_ret_t;
39 typedef HANDLE thr_id_t;
40 
41 #define THREAD_RET_FAILURE (1)
42 #define THREAD_RET_SUCCESS (0)
43 #endif
44 
46 typedef thrd_ret_t(THREAD_CALL_CONV *thr_run_fnc)(void *);
47 
48 extern int thread_start(thr_id_t *thr_p, thr_run_fnc t_fnc, void *t_fnc_arg);
49 extern int thread_affinity_set(thr_id_t thr, unsigned core);
50 extern int thread_wait(thr_id_t thr, thrd_ret_t *ret);
51 extern unsigned thread_cores_count(void);
Determine on what OS we are compiling.
thrd_ret_t(THREAD_CALL_CONV * thr_run_fnc)(void *)
The function type of a new thread entry point.
Definition: thread.h:46
int thread_wait(thr_id_t thr, thrd_ret_t *ret)
Wait for specified thread to complete execution.
int thread_affinity_set(thr_id_t thr, unsigned core)
Sets a core affinity for a thread.
unsigned thread_cores_count(void)
Computes the count of available cores on the machine.
int thread_start(thr_id_t *thr_p, thr_run_fnc t_fnc, void *t_fnc_arg)
Creates a thread.