Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
96e8152cd36aa5210cb6065104668ed137d48c09
[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 #include "xbt/misc.h"
18 #include "gras/transport.h"
19 #include "gras/datadesc.h"
20
21 BEGIN_DECL
22
23 /* msgtype declaration and retrival */
24 typedef struct s_gras_msgtype gras_msgtype_t;
25
26 void gras_msgtype_declare  (const char            *name,
27                             gras_datadesc_type_t  *payload);
28 void gras_msgtype_declare_v(const char            *name,
29                             short int              version,
30                             gras_datadesc_type_t  *payload);
31
32 gras_msgtype_t *gras_msgtype_by_name (const char     *name);
33 gras_msgtype_t *gras_msgtype_by_namev(const char      *name,
34                                       short int        version);
35
36 /**
37  * gras_cb_t:
38  * @msg: The message itself
39  * @Returns: true if the message was consumed by the callback.
40  *
41  * Type of message callback functions. Once a such a function is registered to 
42  * handle messages of a given type with RegisterCallback(), it will be called 
43  * each time such a message incomes.
44  *
45  * If the callback accepts the message, it should free it after use.
46  */
47 typedef int (*gras_cb_t)(gras_socket_t        *expeditor,
48                          void                 *payload);
49 void gras_cb_register  (gras_msgtype_t *msgtype,
50                         gras_cb_t       cb);
51 void gras_cb_unregister(gras_msgtype_t *msgtype,
52                         gras_cb_t     cb);
53
54 gras_error_t gras_msg_send(gras_socket_t  *sock,
55                            gras_msgtype_t *msgtype,
56                            void           *payload);
57 gras_error_t gras_msg_wait(double                 timeout,    
58                            gras_msgtype_t        *msgt_want,
59                            gras_socket_t        **expeditor,
60                            void                  *payload);
61 gras_error_t gras_msg_handle(double timeOut);
62
63
64 END_DECL
65
66 #endif /* GRAS_MSG_H */
67