1 /* Copyright (c) 2007-2019. 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 SIMGRID_KERNEL_ACTIVITY_MAILBOX_HPP
7 #define SIMGRID_KERNEL_ACTIVITY_MAILBOX_HPP
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/kernel/actor/ActorImpl.hpp"
20 /** @brief Implementation of the s4u::Mailbox */
23 static constexpr size_t MAX_MAILBOX_SIZE = 10000000;
29 friend s4u::Mailbox* s4u::Mailbox::by_name(const std::string& name);
30 friend mc::CommunicationDeterminismChecker;
32 explicit MailboxImpl(const std::string& name)
33 : piface_(this), name_(name), comm_queue_(MAX_MAILBOX_SIZE), done_comm_queue_(MAX_MAILBOX_SIZE)
38 const xbt::string& get_name() const { return name_; }
39 const char* get_cname() const { return name_.c_str(); }
40 static MailboxImpl* by_name_or_null(const std::string& name);
41 static MailboxImpl* by_name_or_create(const std::string& name);
42 void set_receiver(s4u::ActorPtr actor);
43 void push(CommImplPtr comm);
44 void remove(const CommImplPtr& comm);
45 CommImplPtr iprobe(int type, int (*match_fun)(void*, void*, CommImpl*), void* data);
46 CommImplPtr find_matching_comm(CommImpl::Type type, int (*match_fun)(void*, void*, CommImpl*), void* this_user_data,
47 const CommImplPtr& my_synchro, bool done, bool remove_matching);
49 actor::ActorImplPtr permanent_receiver_; // actor to which the mailbox is attached
50 boost::circular_buffer_space_optimized<CommImplPtr> comm_queue_;
51 boost::circular_buffer_space_optimized<CommImplPtr> done_comm_queue_; // messages already received in the permanent
54 } // namespace activity
56 } // namespace simgrid
58 XBT_PRIVATE void SIMIX_mailbox_exit();