Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Useless cleanup
[simgrid.git] / include / gras / 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_error_t gras_msgtype_declare_v(const char            *name,
44                                     short int              version,
45                                     gras_datadesc_type_t  *payload);
46
47 gras_error_t gras_msgtype_by_name (const char     *name,
48                                    gras_msgtype_t **dst);
49 gras_error_t gras_msgtype_by_namev(const char      *name,
50                                    short int        version,
51                                    gras_msgtype_t **dst);
52
53
54 /**
55  * gras_cb_t:
56  * @msg: The message itself
57  * @Returns: true if the message was consumed by the callback.
58  *
59  * Type of message callback functions. Once a such a function is registered to 
60  * handle messages of a given type with RegisterCallback(), it will be called 
61  * each time such a message incomes.
62  *
63  * If the callback accepts the message, it should free it after use.
64  */
65 typedef int (*gras_cb_t)(gras_socket_t        *expeditor,
66                          void                 *payload);
67 gras_error_t gras_cb_register  (gras_msgtype_t *msgtype,
68                                 gras_cb_t       cb);
69 void         gras_cb_unregister(gras_msgtype_t *msgtype,
70                                 gras_cb_t     cb);
71
72 gras_error_t gras_msg_send(gras_socket_t  *sock,
73                            gras_msgtype_t *msgtype,
74                            void           *payload);
75 gras_error_t gras_msg_wait(double                 timeout,    
76                            gras_msgtype_t        *msgt_want,
77                            gras_socket_t        **expeditor,
78                            void                  *payload);
79 gras_error_t gras_msg_handle(double timeOut);
80
81
82 END_DECL
83
84 #endif /* GRAS_MSG_H */
85