1 /* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMIX_MAILBOXIMPL_H
7 #define SIMIX_MAILBOXIMPL_H
9 #include <boost/circular_buffer.hpp>
11 #include "simgrid/s4u/Mailbox.hpp"
12 #include "src/kernel/activity/CommImpl.hpp"
13 #include "src/simix/ActorImpl.hpp"
15 #define MAX_MAILBOX_SIZE 10000000
20 /** @brief Implementation of the simgrid::s4u::Mailbox */
23 explicit MailboxImpl(const char* name)
24 : piface_(this), name_(xbt_strdup(name)), comm_queue(MAX_MAILBOX_SIZE), done_comm_queue(MAX_MAILBOX_SIZE)
29 ~MailboxImpl() { xbt_free(name_); }
31 static MailboxImpl* byNameOrNull(const char* name);
32 static MailboxImpl* byNameOrCreate(const char* name);
33 void setReceiver(s4u::ActorPtr actor);
34 void push(activity::CommImplPtr comm);
35 void remove(smx_activity_t activity);
36 simgrid::s4u::Mailbox piface_; // Our interface
39 simgrid::simix::ActorImplPtr permanent_receiver; // process which the mailbox is attached to
40 boost::circular_buffer_space_optimized<smx_activity_t> comm_queue;
41 boost::circular_buffer_space_optimized<smx_activity_t> done_comm_queue; // messages already received in the permanent receive mode
47 XBT_PRIVATE void SIMIX_mailbox_exit();
49 #endif /* SIMIX_MAILBOXIMPL_H */