Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename xbt_thread, xbt_mutex and xbt_thcond to xbt_os_thread, xbt_os_mutex and xbt_os...
[simgrid.git] / src / include / xbt / xbt_os_thread.h
1 /* $Id$ */
2
3 /* xbt/xbt_thread.h -- Thread portability layer                             */
4
5 /* Copyright (c) 2007 Martin Quinson. All rights reserved.                  */
6
7 /* This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. */
9
10
11 #ifndef _XBT_OS_THREAD_H
12 #define _XBT_OS_THREAD_H
13
14 #include "xbt/misc.h" /* SG_BEGIN_DECL */
15 #include "xbt/function_types.h"
16
17 SG_BEGIN_DECL()
18
19 /** @addtogroup XBT_thread
20  *  @brief Thread portability layer
21  * 
22  *  This section describes the thread portability layer. It defines types and 
23  *  functions very close to the pthread API, but it's portable to windows too.
24  * 
25  *  @{
26  */
27
28   /** \brief Thread data type (opaque structure) */
29   typedef struct xbt_os_thread_       *xbt_os_thread_t;
30
31   XBT_PUBLIC(xbt_os_thread_t) xbt_os_thread_create(pvoid_f_pvoid_t start_routine,void* param);
32   XBT_PUBLIC(void) xbt_os_thread_exit(int *retcode);
33   XBT_PUBLIC(xbt_os_thread_t) xbt_os_thread_self(void);
34   /* xbt_os_thread_join frees the joined thread (ie the XBT wrapper around it, the OS frees the rest) */
35   XBT_PUBLIC(void) xbt_os_thread_join(xbt_os_thread_t thread,void ** thread_return);
36   XBT_PUBLIC(void) xbt_os_thread_yield(void);
37
38
39   /** \brief Thread mutex data type (opaque structure) */
40   typedef struct xbt_os_mutex_ *xbt_os_mutex_t;
41
42   XBT_PUBLIC(xbt_os_mutex_t) xbt_os_mutex_init(void);
43   XBT_PUBLIC(void)           xbt_os_mutex_lock(xbt_os_mutex_t mutex);
44   XBT_PUBLIC(void)           xbt_os_mutex_unlock(xbt_os_mutex_t mutex);
45   XBT_PUBLIC(void)           xbt_os_mutex_destroy(xbt_os_mutex_t mutex);
46
47
48   /** \brief Thread condition data type (opaque structure) */
49   typedef struct xbt_os_cond_  *xbt_os_cond_t;
50
51   XBT_PUBLIC(xbt_os_cond_t) xbt_os_cond_init(void);
52   XBT_PUBLIC(void)          xbt_os_cond_wait(xbt_os_cond_t cond,
53                                              xbt_os_mutex_t mutex);
54   XBT_PUBLIC(void)          xbt_os_cond_signal(xbt_os_cond_t cond);
55   XBT_PUBLIC(void)          xbt_os_cond_broadcast(xbt_os_cond_t cond);
56   XBT_PUBLIC(void)          xbt_os_cond_destroy(xbt_os_cond_t cond);
57
58 /** @} */
59
60 SG_END_DECL()
61
62 #endif /* _XBT_OS_THREAD_H */