Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Stupid me. Using rand to generate the datatest is not very wise...
[simgrid.git] / include / messages.h
1 /* $Id$ */
2
3 /* messaging - high level communication (send/receive messages)             */
4
5 /* module's public interface exported to end user.                          */
6
7 /* Authors: Martin Quinson                                                  */
8 /* Copyright (C) 2003, 2004 Martin Quinson.                                 */
9
10 /* This program is free software; you can redistribute it and/or modify it
11    under the terms of the license (GNU LGPL) which comes with this package. */
12
13
14 #ifndef GRAS_MESSAGES_H
15 #define GRAS_MESSAGES_H
16
17 /*! C++ users need love */
18 #ifndef BEGIN_DECL
19 # ifdef __cplusplus
20 #  define BEGIN_DECL extern "C" {
21 # else
22 #  define BEGIN_DECL 
23 # endif
24 #endif
25
26 /*! C++ users need love */
27 #ifndef END_DECL
28 # ifdef __cplusplus
29 #  define END_DECL }
30 # else
31 #  define END_DECL 
32 # endif
33 #endif
34 /* End of cruft for C++ */
35
36 BEGIN_DECL
37
38 /* msgtype declaration and retrival */
39 typedef struct s_gras_msgtype gras_msgtype_t;
40
41 gras_error_t gras_msgtype_declare  (const char            *name,
42                                     gras_datadesc_type_t  *payload,
43                                     gras_msgtype_t       **dst);
44 gras_error_t gras_msgtype_declare_v(const char            *name,
45                                     short int              version,
46                                     gras_datadesc_type_t  *payload,
47                                     gras_msgtype_t       **dst);
48
49 gras_error_t gras_msgtype_by_name (const char     *name,
50                                    gras_msgtype_t **dst);
51 gras_error_t gras_msgtype_by_namev(const char      *name,
52                                    short int        version,
53                                    gras_msgtype_t **dst);
54
55
56 /**
57  * gras_cb_t:
58  * @msg: The message itself
59  * @Returns: true if the message was consumed by the callback.
60  *
61  * Type of message callback functions. Once a such a function is registered to 
62  * handle messages of a given type with RegisterCallback(), it will be called 
63  * each time such a message incomes.
64  *
65  * If the callback accepts the message, it should free it after use.
66  */
67 typedef int (*gras_cb_t)(gras_socket_t        *expeditor,
68                          void                 *payload);
69 gras_error_t gras_cb_register  (gras_msgtype_t *msgtype,
70                                 gras_cb_t       cb);
71 void         gras_cb_unregister(gras_msgtype_t *msgtype,
72                                 gras_cb_t     cb);
73
74 gras_error_t gras_msg_send(gras_socket_t  *sock,
75                            gras_msgtype_t *msgtype,
76                            void           *payload);
77 gras_error_t gras_msg_wait(double                 timeout,    
78                            gras_msgtype_t        *msgt_want,
79                            gras_socket_t        **expeditor,
80                            void                  *payload);
81 gras_error_t gras_msg_handle(double timeOut);
82
83
84 END_DECL
85
86 #endif /* GRAS_MSG_H */
87