Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
rw_thread.h
Go to the documentation of this file.
1
29#ifndef RW_RWTHREAD_H_INCLUDED
30#define RW_RWTHREAD_H_INCLUDED
31
32#include <rw_testdefs.h>
33
34
35extern "C" {
36 typedef void* rw_thread_proc (void*);
37} // extern "C"
38
39struct rw_thread_attr_t;
40
42{
43 long threadno; // 0-based unique thread number
44 long id; // thread id
45 void* handle; // thread handle
46};
47
48
49// same as POSIX pthread_create()
52 rw_thread_attr_t*,
54 void*);
55
56
57// same as POSIX pthread_join()
60
61
62// create a pool of nthreads, passing each a successive element
63// of argarray as argument (if non-null) and filling the tidarray
64// array with their id's; if (tidarray == 0), waits for all
65// threads to join and fills the aragarray with the result
66// returned from each thread
67// if (timeout != 0), then a timer will be started, and the function
68// rw_thread_pool_timeout_expired() will return true after that number
69// of seconds has passed. there is only one timer, so use timeouts
70// with caution. if you provide tidarray, you should join threads
71// before starting another pool, otherwise threads from the first
72// pool may not exit until the threads from a later second pool are
73// signalled to stop.
74// if (nthreads == SIZE_MAX), sets nthreads to the positive result
75// of rw_get_processors() plus 1, or to 2 otherwise
76// returns 0 on success, or a non-zero value indicating the thread
77// number that failed to create on error
79rw_thread_pool (rw_thread_t* /* tidarray */,
80 _RWSTD_SIZE_T /* nthreads */,
81 rw_thread_attr_t* /* attr */,
82 rw_thread_proc* /* thr_proc */,
83 void** /* argarray */,
84 _RWSTD_SIZE_T /* timeout */ = 0);
85
86// returns non-zero if the thread timeout flag has been set. should
87// be polled periodically by threads created by rw_thread_pool() so
88// that they know that the soft timeout has expired
89// see notes above for details
92
93// returns the number of logical processors/cores on the system,
94// or -1 on error
97
98#endif // RW_RWTHREAD_H_INCLUDED
#define _TEST_EXPORT
Definition rw_testdefs.h:55
void * rw_thread_proc(void *)
Definition rw_thread.h:36
_TEST_EXPORT int rw_thread_create(rw_thread_t *, rw_thread_attr_t *, rw_thread_proc *, void *)
Definition thread.cpp:379
_TEST_EXPORT int rw_thread_join(rw_thread_t, void **)
Definition thread.cpp:391
_TEST_EXPORT int rw_thread_pool(rw_thread_t *, _RWSTD_SIZE_T, rw_thread_attr_t *, rw_thread_proc *, void **, _RWSTD_SIZE_T=0)
_TEST_EXPORT int rw_get_cpus()
Definition thread.cpp:402
_TEST_EXPORT int rw_thread_pool_timeout_expired()
Definition thread.cpp:65
long threadno
Definition rw_thread.h:43
void * handle
Definition rw_thread.h:45