3 /* gras message types handling */
5 /* Copyright (c) 2003, 2004, 2005, 2006, 2007 Martin Quinson. */
6 /* All rights reserved. */
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. */
12 #include "gras/Msg/msg_private.h"
13 #include "gras/Virtu/virtu_interface.h"
15 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(gras_msg);
17 extern xbt_set_t _gras_msgtype_set;
20 * Creating procdata for this module
22 static void *gras_msg_procdata_new() {
23 gras_msg_procdata_t res = xbt_new(s_gras_msg_procdata_t,1);
25 res->name = xbt_strdup("gras_msg");
27 res->msg_queue = xbt_dynar_new(sizeof(s_gras_msg_t), NULL);
28 res->msg_waitqueue = xbt_dynar_new(sizeof(s_gras_msg_t), NULL);
29 res->cbl_list = xbt_dynar_new(sizeof(gras_cblist_t *),gras_cbl_free);
30 res->timers = xbt_dynar_new(sizeof(s_gras_timer_t), NULL);
31 res->msg_to_receive_queue = xbt_fifo_new();
32 res->msg_to_receive_queue_meas = xbt_fifo_new();
38 * Freeing procdata for this module
40 static void gras_msg_procdata_free(void *data) {
41 gras_msg_procdata_t res = (gras_msg_procdata_t)data;
43 xbt_dynar_free(&( res->msg_queue ));
44 xbt_dynar_free(&( res->msg_waitqueue ));
45 xbt_dynar_free(&( res->cbl_list ));
46 xbt_dynar_free(&( res->timers ));
47 xbt_fifo_free( res->msg_to_receive_queue );
48 xbt_fifo_free( res->msg_to_receive_queue_meas );
57 int gras_msg_libdata_id;
58 void gras_msg_register() {
59 gras_msg_libdata_id = gras_procdata_add("gras_msg",gras_msg_procdata_new, gras_msg_procdata_free);
63 * Initialize this submodule.
65 void gras_msg_init(void) {
66 /* only initialize once */
67 if (_gras_msgtype_set != NULL)
70 VERB0("Initializing Msg");
72 _gras_msgtype_set = xbt_set_new();
74 memcpy(_GRAS_header,"GRAS", 4);
75 _GRAS_header[4]=GRAS_PROTOCOL_VERSION;
76 _GRAS_header[5]=(char)GRAS_THISARCH;
78 gras_msg_ctx_mallocator =
79 xbt_mallocator_new(1000,
80 gras_msg_ctx_mallocator_new_f,
81 gras_msg_ctx_mallocator_free_f,
82 gras_msg_ctx_mallocator_reset_f);
86 * Finalize the msg module
91 xbt_set_free(&_gras_msgtype_set);
93 xbt_mallocator_free(gras_msg_ctx_mallocator);