1 /* Copyright (c) 2007-2018. 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>
10 #include <xbt/string.hpp>
12 #include "simgrid/s4u/Mailbox.hpp"
13 #include "src/kernel/activity/CommImpl.hpp"
14 #include "src/simix/ActorImpl.hpp"
16 #define MAX_MAILBOX_SIZE 10000000
21 /** @brief Implementation of the simgrid::s4u::Mailbox */
25 friend s4u::MailboxPtr s4u::Mailbox::by_name(std::string name);
26 friend mc::CommunicationDeterminismChecker;
28 explicit MailboxImpl(std::string name)
29 : piface_(this), name_(name), comm_queue_(MAX_MAILBOX_SIZE), done_comm_queue_(MAX_MAILBOX_SIZE)
34 const simgrid::xbt::string& get_name() const { return name_; }
35 const char* get_cname() const { return name_.c_str(); }
36 static MailboxImpl* by_name_or_null(std::string name);
37 static MailboxImpl* by_name_or_create(std::string name);
38 void set_receiver(s4u::ActorPtr actor);
39 void push(activity::CommImplPtr comm);
40 void remove(smx_activity_t activity);
43 simgrid::s4u::Mailbox piface_;
44 simgrid::xbt::string name_;
47 simgrid::kernel::actor::ActorImplPtr permanent_receiver_; // actor to which the mailbox is attached
48 boost::circular_buffer_space_optimized<smx_activity_t> comm_queue_;
49 boost::circular_buffer_space_optimized<smx_activity_t>
50 done_comm_queue_; // messages already received in the permanent receive mode
56 XBT_PRIVATE void SIMIX_mailbox_exit();
58 #endif /* SIMIX_MAILBOXIMPL_H */