Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
6e8b0ad84ea86e7bd1f20831e9580b3295ce2104
[simgrid.git] / src / gras / Msg / msg_private.h
1 /* $Id$ */
2
3 /* messaging - high level communication (send/receive messages)             */
4
5 /* module's private interface masked even to other parts of GRAS.           */
6
7 /* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved.            */
8
9 /* This program is free software; you can redistribute it and/or modify it
10  * under the terms of the license (GNU LGPL) which comes with this package. */
11
12 #ifndef GRAS_MESSAGE_PRIVATE_H
13 #define GRAS_MESSAGE_PRIVATE_H
14
15 #include "gras_config.h"
16
17 #include "xbt/sysdep.h"
18 #include "xbt/log.h"
19 #include "xbt/dynar.h"
20 #include "xbt/set.h"
21 #include "gras/transport.h"
22 #include "gras/datadesc.h"
23 #include "gras/virtu.h"
24
25 #include "gras/messages.h"
26 #include "gras/timer.h"
27 #include "gras_modinter.h"
28
29 #include "gras/Msg/msg_interface.h"
30
31 extern char _GRAS_header[6];
32  
33 /** @brief Message instance */
34 typedef struct {
35   gras_socket_t   expeditor;
36   gras_msgtype_t  type;
37   void           *payload;
38   int             payload_size;
39 } s_gras_msg_t, *gras_msg_t;
40
41 /**
42  * gras_msgtype_t:
43  *
44  * Message type descriptor. There one of these for each registered version.
45  */
46 typedef struct s_gras_msgtype {
47   /* headers for the data set */
48   unsigned int   code;
49   char          *name;
50   unsigned int   name_len;
51         
52   /* payload */
53   short int version;
54   gras_datadesc_type_t ctn_type;
55 } s_gras_msgtype_t;
56
57 extern xbt_set_t _gras_msgtype_set; /* of gras_msgtype_t */
58 void gras_msgtype_free(void *msgtype);
59
60
61 void gras_msg_recv(gras_socket_t    sock,
62                    gras_msgtype_t  *msgtype,
63                    void           **payload,
64                    int             *payload_size);
65
66 /**
67  * gras_cblist_t:
68  *
69  * association between msg ID and cb list for a given process
70  */
71 struct s_gras_cblist {
72   long int id;
73   xbt_dynar_t cbs; /* of gras_msg_cb_t */
74 };
75
76 typedef struct s_gras_cblist gras_cblist_t;
77 void gras_cbl_free(void *); /* used to free the memory at the end */
78 void gras_cblist_free(void *cbl);
79
80
81 /* ********* *
82  * * TIMER * *
83  * ********* */
84 typedef struct {
85   double expiry;
86   double period;
87   void_f_void_t action;
88   int repeat;
89 } s_gras_timer_t, *gras_timer_t;
90
91 /* returns 0 if it handled a timer, or the delay until next timer, or -1 if no armed timer */
92 double gras_msg_timer_handle(void);
93
94
95 #endif  /* GRAS_MESSAGE_PRIVATE_H */