From: Martin Quinson Date: Mon, 13 Feb 2017 22:49:10 +0000 (+0100) Subject: move MailboxImpl to kernel::activity where it belongs X-Git-Tag: v3_15~403 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/1bf8ac043266839571c3a5fa789557fff825db5a move MailboxImpl to kernel::activity where it belongs --- diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index 56c644edeb..11d682c62e 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -134,7 +134,7 @@ namespace s4u { XBT_PUBLIC_CLASS Actor { friend Mailbox; friend simgrid::simix::ActorImpl; - friend simgrid::simix::MailboxImpl; + friend simgrid::kernel::activity::MailboxImpl; simix::ActorImpl* pimpl_ = nullptr; /** Wrap a (possibly non-copyable) single-use task into a `std::function` */ diff --git a/include/simgrid/s4u/Mailbox.hpp b/include/simgrid/s4u/Mailbox.hpp index 272aa02619..9d52198b07 100644 --- a/include/simgrid/s4u/Mailbox.hpp +++ b/include/simgrid/s4u/Mailbox.hpp @@ -106,11 +106,11 @@ namespace s4u { XBT_PUBLIC_CLASS Mailbox { friend Comm; friend simgrid::s4u::Engine; - friend simgrid::simix::MailboxImpl; + friend simgrid::kernel::activity::MailboxImpl; - simgrid::simix::MailboxImpl* pimpl_; + simgrid::kernel::activity::MailboxImpl* pimpl_; - explicit Mailbox(simix::MailboxImpl * mbox) : pimpl_(mbox) {} + explicit Mailbox(kernel::activity::MailboxImpl * mbox) : pimpl_(mbox) {} /** private function to manage the mailboxes' lifetime (see @ref s4u_raii) */ friend void intrusive_ptr_add_ref(Mailbox*) {} @@ -118,7 +118,7 @@ XBT_PUBLIC_CLASS Mailbox { friend void intrusive_ptr_release(Mailbox*) {} public: /** private function, do not use. FIXME: make me protected */ - simix::MailboxImpl* getImpl() { return pimpl_; } + kernel::activity::MailboxImpl* getImpl() { return pimpl_; } /** Gets the name of that mailbox */ const char *name(); diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 02d8112b02..4105374820 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -19,9 +19,13 @@ namespace kernel { namespace context { class Context; class ContextFactory; -}} + } + namespace activity { + class MailboxImpl; + } + } -namespace simix { + namespace simix { /** @brief Process datatype @ingroup simix_process_management @@ -32,14 +36,13 @@ namespace simix { @{ */ class ActorImpl; class Mutex; - class MailboxImpl; } } typedef simgrid::kernel::context::Context *smx_context_t; typedef simgrid::simix::ActorImpl *smx_actor_t; typedef simgrid::simix::Mutex *smx_mutex_t; -typedef simgrid::simix::MailboxImpl* smx_mailbox_t; +typedef simgrid::kernel::activity::MailboxImpl* smx_mailbox_t; #else diff --git a/src/simix/MailboxImpl.cpp b/src/kernel/activity/MailboxImpl.cpp similarity index 95% rename from src/simix/MailboxImpl.cpp rename to src/kernel/activity/MailboxImpl.cpp index 7a19d18a32..b8ff61276a 100644 --- a/src/simix/MailboxImpl.cpp +++ b/src/kernel/activity/MailboxImpl.cpp @@ -3,7 +3,7 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "src/simix/MailboxImpl.hpp" +#include "src/kernel/activity/MailboxImpl.hpp" #include "src/kernel/activity/SynchroComm.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_mailbox, simix, "Mailbox implementation"); @@ -22,7 +22,8 @@ void SIMIX_mailbox_exit() /******************************************************************************/ namespace simgrid { -namespace simix { +namespace kernel { +namespace activity { /** @brief Returns the mailbox of that name, or nullptr */ MailboxImpl* MailboxImpl::byNameOrNull(const char* name) { @@ -35,7 +36,7 @@ MailboxImpl* MailboxImpl::byNameOrCreate(const char* name) /* two processes may have pushed the same mbox_create simcall at the same time */ smx_mailbox_t mbox = static_cast(xbt_dict_get_or_null(mailboxes, name)); if (!mbox) { - mbox = new simgrid::simix::MailboxImpl(name); + mbox = new MailboxImpl(name); XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name); xbt_dict_set(mailboxes, mbox->name_, mbox, nullptr); } @@ -75,3 +76,4 @@ void MailboxImpl::remove(smx_activity_t activity) } } } +} diff --git a/src/simix/MailboxImpl.hpp b/src/kernel/activity/MailboxImpl.hpp similarity index 85% rename from src/simix/MailboxImpl.hpp rename to src/kernel/activity/MailboxImpl.hpp index 4fb573ff7a..f62d3266f3 100644 --- a/src/simix/MailboxImpl.hpp +++ b/src/kernel/activity/MailboxImpl.hpp @@ -13,9 +13,10 @@ #define MAX_MAILBOX_SIZE 10000000 namespace simgrid { -namespace simix { +namespace kernel { +namespace activity { -/** @brief Rendez-vous point datatype */ +/** @brief Implementation of the simgrid::s4u::Mailbox */ class MailboxImpl { explicit MailboxImpl(const char* name) @@ -34,12 +35,13 @@ public: simgrid::s4u::Mailbox piface_; // Our interface char* name_; - boost::intrusive_ptr permanent_receiver; //process which the mailbox is attached to + boost::intrusive_ptr permanent_receiver; // process which the mailbox is attached to boost::circular_buffer_space_optimized comm_queue; - boost::circular_buffer_space_optimized done_comm_queue;//messages already received in the permanent receive mode + boost::circular_buffer_space_optimized done_comm_queue; // messages already received in the permanent receive mode }; } } +} XBT_PRIVATE void SIMIX_mailbox_exit(); diff --git a/src/s4u/s4u_mailbox.cpp b/src/s4u/s4u_mailbox.cpp index ed78c0338c..2fa5db2809 100644 --- a/src/s4u/s4u_mailbox.cpp +++ b/src/s4u/s4u_mailbox.cpp @@ -22,10 +22,10 @@ const char *Mailbox::name() { MailboxPtr Mailbox::byName(const char*name) { - simix::MailboxImpl* mbox = simix::MailboxImpl::byNameOrNull(name); + kernel::activity::MailboxImpl* mbox = kernel::activity::MailboxImpl::byNameOrNull(name); if (mbox == nullptr) { mbox = simix::kernelImmediate([name] { - return simix::MailboxImpl::byNameOrCreate(name); + return kernel::activity::MailboxImpl::byNameOrCreate(name); }); } return MailboxPtr(&mbox->piface_, true); diff --git a/src/simix/smx_network_private.h b/src/simix/smx_network_private.h index e40096bad8..c238e2e298 100644 --- a/src/simix/smx_network_private.h +++ b/src/simix/smx_network_private.h @@ -8,8 +8,8 @@ #define _SIMIX_NETWORK_PRIVATE_H #include "simgrid/s4u/Mailbox.hpp" +#include "src/kernel/activity/MailboxImpl.hpp" #include "src/simix/ActorImpl.hpp" -#include "src/simix/MailboxImpl.hpp" XBT_PRIVATE smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void *dst_buff, size_t *dst_buff_size, diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 51f098d0df..28f94ddbce 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -362,11 +362,11 @@ set(SIMIX_SRC src/simix/smx_network.cpp src/simix/ActorImpl.cpp src/simix/ActorImpl.hpp - src/simix/MailboxImpl.cpp - src/simix/MailboxImpl.hpp src/simix/smx_synchro.cpp src/simix/popping.cpp src/kernel/activity/ActivityImpl.cpp + src/kernel/activity/MailboxImpl.cpp + src/kernel/activity/MailboxImpl.hpp src/kernel/activity/SynchroComm.cpp src/kernel/activity/SynchroExec.cpp src/kernel/activity/SynchroSleep.cpp