From b89dabb5f10155bc54ae983a156d5cc5a810c9ed Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Wed, 8 Aug 2012 11:18:40 +0200 Subject: [PATCH] Add a MSG_mailbox_set_async function to allow to set a mailbox to eagerly receive messages (the message is sent without waiting for the receive) --- include/msg/msg.h | 3 +++ src/msg/msg_mailbox.c | 8 ++++++++ src/msg/msg_mailbox.h | 13 +++++++++++++ 3 files changed, 24 insertions(+) diff --git a/include/msg/msg.h b/include/msg/msg.h index e3b5ac1ce8..24bf774bb5 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -263,6 +263,9 @@ XBT_PUBLIC(msg_error_t) MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task, double timeout); +void MSG_mailbox_set_async(const char *alias); + + /************************** Action handling **********************************/ msg_error_t MSG_action_trace_run(char *path); diff --git a/src/msg/msg_mailbox.c b/src/msg/msg_mailbox.c index 8d1e7c9ed1..d8509ed30b 100644 --- a/src/msg/msg_mailbox.c +++ b/src/msg/msg_mailbox.c @@ -56,6 +56,14 @@ msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias) return mailbox; } +void MSG_mailbox_set_async(const char *alias){ + msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias); + + mailbox->permanent_receiver=SIMIX_process_self(); + XBT_VERB("%s mailbox set to receive eagerly for process %p\n",alias, SIMIX_process_self()); + +} + msg_error_t MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, msg_task_t * task, msg_host_t host, double timeout) diff --git a/src/msg/msg_mailbox.h b/src/msg/msg_mailbox.h index ded6199e64..9f3f37915c 100644 --- a/src/msg/msg_mailbox.h +++ b/src/msg/msg_mailbox.h @@ -66,6 +66,19 @@ XBT_PUBLIC(msg_mailbox_t) */ XBT_PUBLIC(int) MSG_mailbox_is_empty(msg_mailbox_t mailbox); +/* \brief MSG_mailbox_set_async - set a mailbox as eager + * + * The function MSG_mailbox_set_async sets the mailbox to a permanent receiver mode + * Messages sent to this mailbox will then be sent just after the send is issued, + * without waiting for the corresponding receive. + * + * This call should be done before issuing any receive, and on the receiver's side only + * + * \param alias The alias of the mailbox to modify. + * + */ +void MSG_mailbox_set_async(const char *alias); + /*! \brief MSG_mailbox_get_head - get the task at the head of a mailbox. * * The MSG_mailbox_get_head returns the task at the head of the mailbox. -- 2.20.1