2003-01-12 Alp Toker <alp@atoker.com>
[mono.git] / mono / io-layer / timed-thread.h
1 /*
2  * timed-thread.h:  Implementation of timed thread joining
3  *
4  * Author:
5  *      Dick Porter (dick@ximian.com)
6  *
7  * (C) 2002 Ximian, Inc.
8  */
9
10 #ifndef _WAPI_TIMED_THREAD_H_
11 #define _WAPI_TIMED_THREAD_H_
12
13 #include <config.h>
14 #include <glib.h>
15 #include <pthread.h>
16 #ifdef HAVE_SEMAPHORE_H
17 #include <semaphore.h>
18 #endif
19
20 #include "mono-mutex.h"
21
22 typedef struct
23 {
24         pthread_t id;
25         mono_mutex_t join_mutex;
26         pthread_cond_t exit_cond;
27         guint32 create_flags;
28         sem_t suspend_sem;
29         guint32 (*start_routine)(gpointer arg);
30         void (*exit_routine)(guint32 exitstatus, gpointer userdata);
31         gpointer arg;
32         gpointer exit_userdata;
33         guint32 exitstatus;
34         gboolean exiting;
35 } TimedThread;
36
37 extern void _wapi_timed_thread_exit(guint32 exitstatus) G_GNUC_NORETURN;
38 extern int _wapi_timed_thread_create(TimedThread **threadp,
39                                      const pthread_attr_t *attr,
40                                      guint32 create_flags,
41                                      guint32 (*start_routine)(gpointer),
42                                      void (*exit_routine)(guint32, gpointer),
43                                      gpointer arg, gpointer exit_userdata);
44 extern int _wapi_timed_thread_attach(TimedThread **threadp,
45                                      void (*exit_routine)(guint32, gpointer),
46                                      gpointer exit_userdata);
47 extern int _wapi_timed_thread_join(TimedThread *thread,
48                                    struct timespec *timeout,
49                                    guint32 *exitstatus);
50 extern void _wapi_timed_thread_destroy (TimedThread *thread);
51 extern void _wapi_timed_thread_suspend (TimedThread *thread);
52 extern void _wapi_timed_thread_resume (TimedThread *thread);
53
54 #endif /* _WAPI_TIMED_THREAD_H_ */