Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #228 from Takishipp/actor-execute
[simgrid.git] / src / kernel / activity / MailboxImpl.hpp
1 /* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #ifndef SIMIX_MAILBOXIMPL_H
7 #define SIMIX_MAILBOXIMPL_H
8
9 #include <boost/circular_buffer.hpp>
10 #include <xbt/string.hpp>
11
12 #include "simgrid/s4u/Mailbox.hpp"
13 #include "src/kernel/activity/CommImpl.hpp"
14 #include "src/simix/ActorImpl.hpp"
15
16 #define MAX_MAILBOX_SIZE 10000000
17 namespace simgrid {
18 namespace kernel {
19 namespace activity {
20
21 /** @brief Implementation of the simgrid::s4u::Mailbox */
22
23 class MailboxImpl {
24   explicit MailboxImpl(const char* name)
25       : piface_(this), name_(name), comm_queue(MAX_MAILBOX_SIZE), done_comm_queue(MAX_MAILBOX_SIZE)
26   {
27   }
28
29 public:
30   const simgrid::xbt::string& getName() const { return name_; }
31   const char* getCname() const { return name_.c_str(); }
32   static MailboxImpl* byNameOrNull(const char* name);
33   static MailboxImpl* byNameOrCreate(const char* name);
34   void setReceiver(s4u::ActorPtr actor);
35   void push(activity::CommImplPtr comm);
36   void remove(smx_activity_t activity);
37   simgrid::s4u::Mailbox piface_; // Our interface
38   simgrid::xbt::string name_;
39
40   simgrid::simix::ActorImplPtr permanent_receiver; // process which the mailbox is attached to
41   boost::circular_buffer_space_optimized<smx_activity_t> comm_queue;
42   boost::circular_buffer_space_optimized<smx_activity_t> done_comm_queue; // messages already received in the permanent receive mode
43 };
44 }
45 }
46 }
47
48 XBT_PRIVATE void SIMIX_mailbox_exit();
49
50 #endif /* SIMIX_MAILBOXIMPL_H */