new timed thread abstraction layer
[monky] / src / timed_thread.h
1 /* $Id $ */
2
3 /* timed_thread.h
4  * Author: Philip Kovacs 
5  *
6  * Abstraction layer for timed threads
7  * */
8
9
10 #define MINIMUM_INTERVAL_USECS 50000  /* 50000 microseconds = 50 ms =  0.05 sec */
11
12 /* opaque structure for clients */
13 typedef struct _timed_thread timed_thread;
14
15 /* create a timed thread */
16 timed_thread* timed_thread_create (void *(*start_routine)(void*), void *arg, unsigned int interval_ms);
17
18 /* destroy a timed thread */
19 void timed_thread_destroy (timed_thread* p_timed_thread, timed_thread** addr_of_p_timed_thread);
20
21 /* lock a timed thread for critical section activity */
22 int timed_thread_lock (timed_thread* p_timed_thread);
23
24 /* unlock a timed thread after critical section activity */
25 int timed_thread_unlock (timed_thread* p_timed_thread);
26
27 /* waits required interval for termination signal and returns 1 if got it, 0 otherwise */
28 int timed_thread_test (timed_thread* p_timed_thread);
29
30 /* exit a timed thread */
31 void timed_thread_exit (timed_thread* p_timed_thread);
32
33 /* register a timed thread for future destruction */
34 int timed_thread_register (timed_thread* p_timed_thread, timed_thread** addr_of_p_timed_thread);
35
36 /* destroy all registered timed threads */
37 void timed_thread_destroy_registered_threads (void);