Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Main Page
Related Pages
Topics
Namespaces
Data Structures
Files
File List
Globals
EXTERNAL_HEADERS
RSL
tests
include
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
35
extern
"C"
{
36
typedef
void
*
rw_thread_proc
(
void
*);
37
}
// extern "C"
38
39
struct
rw_thread_attr_t;
40
41
struct
rw_thread_t
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()
50
_TEST_EXPORT
int
51
rw_thread_create
(
rw_thread_t
*,
52
rw_thread_attr_t*,
53
rw_thread_proc
*,
54
void
*);
55
56
57
// same as POSIX pthread_join()
58
_TEST_EXPORT
int
59
rw_thread_join
(
rw_thread_t
,
void
**);
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
78
_TEST_EXPORT
int
79
rw_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
90
_TEST_EXPORT
int
91
rw_thread_pool_timeout_expired
();
92
93
// returns the number of logical processors/cores on the system,
94
// or -1 on error
95
_TEST_EXPORT
int
96
rw_get_cpus
();
97
98
#endif
// RW_RWTHREAD_H_INCLUDED
rw_testdefs.h
_TEST_EXPORT
#define _TEST_EXPORT
Definition
rw_testdefs.h:55
rw_thread_proc
void * rw_thread_proc(void *)
Definition
rw_thread.h:36
rw_thread_create
_TEST_EXPORT int rw_thread_create(rw_thread_t *, rw_thread_attr_t *, rw_thread_proc *, void *)
Definition
thread.cpp:379
rw_thread_join
_TEST_EXPORT int rw_thread_join(rw_thread_t, void **)
Definition
thread.cpp:391
rw_thread_pool
_TEST_EXPORT int rw_thread_pool(rw_thread_t *, _RWSTD_SIZE_T, rw_thread_attr_t *, rw_thread_proc *, void **, _RWSTD_SIZE_T=0)
rw_get_cpus
_TEST_EXPORT int rw_get_cpus()
Definition
thread.cpp:402
rw_thread_pool_timeout_expired
_TEST_EXPORT int rw_thread_pool_timeout_expired()
Definition
thread.cpp:65
rw_thread_t
Definition
rw_thread.h:42
rw_thread_t::threadno
long threadno
Definition
rw_thread.h:43
rw_thread_t::id
long id
Definition
rw_thread.h:44
rw_thread_t::handle
void * handle
Definition
rw_thread.h:45
Generated by
1.9.8