Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
e67941ae0254cd5fe16c2e9873cc1203f7e84e90
[simgrid.git] / include / gras / process.h
1 /* $Id$ */
2
3 /* gras/process.h - Manipulating data related to an host.                   */
4
5 /* Copyright (c) 2003, 2004 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 #ifndef GRAS_PROCESS_H
11 #define GRAS_PROCESS_H
12
13 #include "xbt/misc.h"  /* SG_BEGIN_DECL */
14
15 SG_BEGIN_DECL()
16
17 /****************************************************************************/
18 /* Manipulating User Data                                                   */
19 /****************************************************************************/
20
21 /** \addtogroup GRAS_globals
22  *  \brief Handling global variables so that it works on simulator.
23  * 
24  * In GRAS, using globals is forbidden since the "processes" will
25  * sometimes run as a thread inside the same process (namely, in
26  * simulation mode). So, you have to put all globals in a structure, and
27  * let GRAS handle it.
28  * 
29  * Use the \ref gras_userdata_new macro to create a new user data (or malloc it
30  * and use \ref gras_userdata_set yourself), and \ref gras_userdata_get to
31  * retrieve a reference to it. 
32  */
33 /* @{ */
34
35 /**
36  * \brief Get the data associated with the current process.
37  * \ingroup GRAS_globals
38  */
39 XBT_PUBLIC(void*) gras_userdata_get(void);
40
41 /**
42  * \brief Set the data associated with the current process.
43  * \ingroup GRAS_globals
44  */
45 XBT_PUBLIC(void) gras_userdata_set(void *ud);
46
47 /** \brief Malloc and set the data associated with the current process. */
48 #define gras_userdata_new(type) (gras_userdata_set(xbt_new0(type,1)),gras_userdata_get())
49 /* @} */
50
51 SG_END_DECL()
52
53 #endif /* GRAS_PROCESS_H */
54