Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix (C) dates; minor documentation improvements
[simgrid.git] / include / gras / messages.h
1 /* $Id$ */
2
3 /* messaging - high level communication (send/receive messages)             */
4 /* module's public interface exported to end user.                          */
5
6 /* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved.            */
7
8 /* This program is free software; you can redistribute it and/or modify it
9  * under the terms of the license (GNU LGPL) which comes with this package. */
10
11 #ifndef GRAS_MESSAGES_H
12 #define GRAS_MESSAGES_H
13
14 #include "xbt/misc.h"
15 #include "gras/transport.h"
16 #include "gras/datadesc.h"
17
18 BEGIN_DECL
19
20 /* msgtype declaration and retrival */
21 typedef struct s_gras_msgtype *gras_msgtype_t;
22
23 void gras_msgtype_declare  (const char           *name,
24                             gras_datadesc_type_t  payload);
25 void gras_msgtype_declare_v(const char           *name,
26                             short int             version,
27                             gras_datadesc_type_t  payload);
28
29 gras_msgtype_t gras_msgtype_by_name (const char     *name);
30 gras_msgtype_t gras_msgtype_by_namev(const char     *name,
31                                      short int       version);
32
33 /**
34  * gras_cb_t:
35  * @msg: The message itself
36  * @Returns: true if the message was consumed by the callback.
37  *
38  * Type of message callback functions. Once a such a function is registered to 
39  * handle messages of a given type with RegisterCallback(), it will be called 
40  * each time such a message incomes.
41  *
42  * If the callback accepts the message, it should free it after use.
43  */
44 typedef int (*gras_cb_t)(gras_socket_t  expeditor,
45                          void          *payload);
46 void gras_cb_register  (gras_msgtype_t msgtype,
47                         gras_cb_t      cb);
48 void gras_cb_unregister(gras_msgtype_t msgtype,
49                         gras_cb_t      cb);
50
51 xbt_error_t gras_msg_send(gras_socket_t   sock,
52                            gras_msgtype_t  msgtype,
53                            void           *payload);
54 xbt_error_t gras_msg_wait(double          timeout,    
55                            gras_msgtype_t  msgt_want,
56                            gras_socket_t  *expeditor,
57                            void           *payload);
58 xbt_error_t gras_msg_handle(double timeOut);
59
60
61 END_DECL
62
63 #endif /* GRAS_MSG_H */
64