2006-11-14 22:31:12 +00:00
|
|
|
/* $Id$ */
|
2006-11-14 22:30:31 +00:00
|
|
|
|
|
|
|
/* timed_thread.h
|
|
|
|
* Author: Philip Kovacs
|
|
|
|
*
|
|
|
|
* Abstraction layer for timed threads
|
|
|
|
* */
|
|
|
|
|
2006-11-15 01:20:49 +00:00
|
|
|
#ifndef _TIMED_THREAD_H_
|
|
|
|
#define _TIMED_THREAD_H_
|
2006-11-14 22:30:31 +00:00
|
|
|
|
|
|
|
#define MINIMUM_INTERVAL_USECS 50000 /* 50000 microseconds = 50 ms = 0.05 sec */
|
|
|
|
|
|
|
|
/* opaque structure for clients */
|
|
|
|
typedef struct _timed_thread timed_thread;
|
|
|
|
|
|
|
|
/* create a timed thread */
|
2006-11-15 01:20:49 +00:00
|
|
|
timed_thread* timed_thread_create (void *(*start_routine)(void*), void *arg, unsigned int interval_usecs);
|
2006-11-14 22:30:31 +00:00
|
|
|
|
|
|
|
/* destroy a timed thread */
|
|
|
|
void timed_thread_destroy (timed_thread* p_timed_thread, timed_thread** addr_of_p_timed_thread);
|
|
|
|
|
|
|
|
/* lock a timed thread for critical section activity */
|
|
|
|
int timed_thread_lock (timed_thread* p_timed_thread);
|
|
|
|
|
|
|
|
/* unlock a timed thread after critical section activity */
|
|
|
|
int timed_thread_unlock (timed_thread* p_timed_thread);
|
|
|
|
|
|
|
|
/* waits required interval for termination signal and returns 1 if got it, 0 otherwise */
|
|
|
|
int timed_thread_test (timed_thread* p_timed_thread);
|
|
|
|
|
|
|
|
/* exit a timed thread */
|
|
|
|
void timed_thread_exit (timed_thread* p_timed_thread);
|
|
|
|
|
2006-11-15 01:20:49 +00:00
|
|
|
/* register a timed thread for future destruction via timed_thread_destroy_registered_threads() */
|
2006-11-14 22:30:31 +00:00
|
|
|
int timed_thread_register (timed_thread* p_timed_thread, timed_thread** addr_of_p_timed_thread);
|
|
|
|
|
|
|
|
/* destroy all registered timed threads */
|
|
|
|
void timed_thread_destroy_registered_threads (void);
|
2006-11-15 01:20:49 +00:00
|
|
|
|
|
|
|
#endif /* #ifdef _TIMED_THREAD_H_ */
|