static void shutdown();
/** Run the simulation after initialization */
- void run();
+ void run() const;
/** @brief Retrieve the simulation time (in seconds) */
static double get_clock();
/** @brief Retrieve the engine singleton */
static s4u::Engine* get_instance();
- void load_platform(const std::string& platf);
+ void load_platform(const std::string& platf) const;
XBT_ATTRIB_DEPRECATED_v330("Please change the return code of your actors to void") void register_function(
const std::string& name, int (*code)(int, char**));
public:
/** Returns the amount of hosts existing in the platform. */
- size_t get_host_count();
+ size_t get_host_count() const;
/** Returns a vector of all hosts found in the platform.
*
* The order is generally different from the creation/declaration order in the XML platform because we use a hash
* table internally.
*/
- std::vector<Host*> get_all_hosts();
- std::vector<Host*> get_filtered_hosts(const std::function<bool(Host*)>& filter);
- Host* host_by_name(const std::string& name);
- Host* host_by_name_or_null(const std::string& name);
+ std::vector<Host*> get_all_hosts() const;
+ std::vector<Host*> get_filtered_hosts(const std::function<bool(Host*)>& filter) const;
+ Host* host_by_name(const std::string& name) const;
+ Host* host_by_name_or_null(const std::string& name) const;
- size_t get_link_count();
- std::vector<Link*> get_all_links();
- std::vector<Link*> get_filtered_links(const std::function<bool(Link*)>& filter);
- Link* link_by_name(const std::string& name);
- Link* link_by_name_or_null(const std::string& name);
+ size_t get_link_count() const;
+ std::vector<Link*> get_all_links() const;
+ std::vector<Link*> get_filtered_links(const std::function<bool(Link*)>& filter) const;
+ Link* link_by_name(const std::string& name) const;
+ Link* link_by_name_or_null(const std::string& name) const;
- size_t get_actor_count();
- std::vector<ActorPtr> get_all_actors();
- std::vector<ActorPtr> get_filtered_actors(const std::function<bool(ActorPtr)>& filter);
+ size_t get_actor_count() const;
+ std::vector<ActorPtr> get_all_actors() const;
+ std::vector<ActorPtr> get_filtered_actors(const std::function<bool(ActorPtr)>& filter) const;
#ifndef DOXYGEN
- size_t get_storage_count();
- std::vector<Storage*> get_all_storages();
- Storage* storage_by_name(const std::string& name);
- Storage* storage_by_name_or_null(const std::string& name);
+ size_t get_storage_count() const;
+ std::vector<Storage*> get_all_storages() const;
+ Storage* storage_by_name(const std::string& name) const;
+ Storage* storage_by_name_or_null(const std::string& name) const;
#endif
- std::vector<kernel::routing::NetPoint*> get_all_netpoints();
- kernel::routing::NetPoint* netpoint_by_name_or_null(const std::string& name);
+ std::vector<kernel::routing::NetPoint*> get_all_netpoints() const;
+ kernel::routing::NetPoint* netpoint_by_name_or_null(const std::string& name) const;
- NetZone* get_netzone_root();
+ NetZone* get_netzone_root() const;
void set_netzone_root(const NetZone* netzone);
- NetZone* netzone_by_name_or_null(const std::string& name);
+ NetZone* netzone_by_name_or_null(const std::string& name) const;
/** @brief Retrieves all netzones of the type indicated by the template argument */
- template <class T> std::vector<T*> get_filtered_netzones()
+ template <class T> std::vector<T*> get_filtered_netzones() const
{
static_assert(std::is_base_of<kernel::routing::NetZoneImpl, T>::value,
"Filtering netzones is only possible for subclasses of kernel::routing::NetZoneImpl");
* It is not a problem if the actor is not located on the called host.
* The actor will not be migrated in this case. Such remote execution are easy in simulation.
*/
- void execute(double flops);
+ void execute(double flops) const;
/** Start an asynchronous computation on that host (possibly remote) */
- ExecPtr exec_async(double flops_amounts);
+ ExecPtr exec_async(double flops_amounts) const;
/** Block the calling actor on an execution located on the called host (with explicit priority) */
- void execute(double flops, double priority);
+ void execute(double flops, double priority) const;
private:
xbt::string name_{"noname"};
static Mailbox* by_name(const std::string& name);
/** Returns whether the mailbox contains queued communications */
- bool empty();
+ bool empty() const;
/** Check if there is a communication going on in a mailbox. */
- bool listen();
+ bool listen() const;
/** Look if there is a communication going on in a mailbox and return the PID of the sender actor */
- aid_t listen_from();
+ aid_t listen_from() const;
/** Check if there is a communication ready to be consumed from a mailbox. */
- bool ready();
+ bool ready() const;
/** Gets the first element in the queue (without dequeuing it), or nullptr if none is there */
- kernel::activity::CommImplPtr front();
+ kernel::activity::CommImplPtr front() const;
/** Declare that the specified actor is a permanent receiver on that mailbox
*
void set_receiver(ActorPtr actor);
/** Return the actor declared as permanent receiver, or nullptr if none **/
- ActorPtr get_receiver();
+ ActorPtr get_receiver() const;
/** Creates (but don't start) a data transmission to that mailbox */
CommPtr put_init();
* See also: :ref:`platform`.
* \endrst
*/
-void Engine::load_platform(const std::string& platf)
+void Engine::load_platform(const std::string& platf) const
{
double start = xbt_os_time();
parse_platform_file(platf);
}
/** Returns the amount of hosts in the platform */
-size_t Engine::get_host_count()
+size_t Engine::get_host_count() const
{
return pimpl->hosts_.size();
}
-std::vector<Host*> Engine::get_all_hosts()
+std::vector<Host*> Engine::get_all_hosts() const
{
std::vector<Host*> res;
for (auto const& kv : pimpl->hosts_)
return res;
}
-std::vector<Host*> Engine::get_filtered_hosts(const std::function<bool(Host*)>& filter)
+std::vector<Host*> Engine::get_filtered_hosts(const std::function<bool(Host*)>& filter) const
{
std::vector<Host*> hosts;
for (auto const& kv : pimpl->hosts_) {
*
* @throw std::invalid_argument if the searched host does not exist.
*/
-Host* Engine::host_by_name(const std::string& name)
+Host* Engine::host_by_name(const std::string& name) const
{
if (pimpl->hosts_.find(name) == pimpl->hosts_.end())
throw std::invalid_argument(std::string("Host not found: '") + name + std::string("'"));
}
/** @brief Find a host from its name (or nullptr if that host does not exist) */
-Host* Engine::host_by_name_or_null(const std::string& name)
+Host* Engine::host_by_name_or_null(const std::string& name) const
{
auto host = pimpl->hosts_.find(name);
return host == pimpl->hosts_.end() ? nullptr : host->second;
*
* @throw std::invalid_argument if the searched link does not exist.
*/
-Link* Engine::link_by_name(const std::string& name)
+Link* Engine::link_by_name(const std::string& name) const
{
if (pimpl->links_.find(name) == pimpl->links_.end())
throw std::invalid_argument(std::string("Link not found: ") + name);
}
/** @brief Find an link from its name (or nullptr if that link does not exist) */
-Link* Engine::link_by_name_or_null(const std::string& name)
+Link* Engine::link_by_name_or_null(const std::string& name) const
{
auto link = pimpl->links_.find(name);
return link == pimpl->links_.end() ? nullptr : link->second->get_iface();
}
/** @brief Returns the amount of storages in the platform */
-size_t Engine::get_storage_count()
+size_t Engine::get_storage_count() const
{
return pimpl->storages_.size();
}
/** @brief Returns the list of all storages found in the platform */
-std::vector<Storage*> Engine::get_all_storages()
+std::vector<Storage*> Engine::get_all_storages() const
{
std::vector<Storage*> res;
for (auto const& kv : pimpl->storages_)
*
* @throw std::invalid_argument if the searched storage does not exist.
*/
-Storage* Engine::storage_by_name(const std::string& name)
+Storage* Engine::storage_by_name(const std::string& name) const
{
if (pimpl->storages_.find(name) == pimpl->storages_.end())
throw std::invalid_argument(std::string("Storage not found: ") + name);
}
/** @brief Find a storage from its name (or nullptr if that storage does not exist) */
-Storage* Engine::storage_by_name_or_null(const std::string& name)
+Storage* Engine::storage_by_name_or_null(const std::string& name) const
{
auto storage = pimpl->storages_.find(name);
return storage == pimpl->storages_.end() ? nullptr : storage->second->get_iface();
}
/** @brief Returns the amount of links in the platform */
-size_t Engine::get_link_count()
+size_t Engine::get_link_count() const
{
return pimpl->links_.size();
}
/** @brief Returns the list of all links found in the platform */
-std::vector<Link*> Engine::get_all_links()
+std::vector<Link*> Engine::get_all_links() const
{
std::vector<Link*> res;
for (auto const& kv : pimpl->links_)
return res;
}
-std::vector<Link*> Engine::get_filtered_links(const std::function<bool(Link*)>& filter)
+std::vector<Link*> Engine::get_filtered_links(const std::function<bool(Link*)>& filter) const
{
std::vector<Link*> filtered_list;
for (auto const& kv : pimpl->links_) {
return filtered_list;
}
-size_t Engine::get_actor_count()
+size_t Engine::get_actor_count() const
{
return simix_global->process_list.size();
}
-std::vector<ActorPtr> Engine::get_all_actors()
+std::vector<ActorPtr> Engine::get_all_actors() const
{
std::vector<ActorPtr> actor_list;
for (auto const& kv : simix_global->process_list) {
return actor_list;
}
-std::vector<ActorPtr> Engine::get_filtered_actors(const std::function<bool(ActorPtr)>& filter)
+std::vector<ActorPtr> Engine::get_filtered_actors(const std::function<bool(ActorPtr)>& filter) const
{
std::vector<ActorPtr> actor_list;
for (auto const& kv : simix_global->process_list) {
return actor_list;
}
-void Engine::run()
+void Engine::run() const
{
/* Clean IO before the run */
fflush(stdout);
}
/** @brief Retrieve the root netzone, containing all others */
-s4u::NetZone* Engine::get_netzone_root()
+s4u::NetZone* Engine::get_netzone_root() const
{
return pimpl->netzone_root_->get_iface();
}
}
/** @brief Retrieve the NetZone of the given name (or nullptr if not found) */
-NetZone* Engine::netzone_by_name_or_null(const std::string& name)
+NetZone* Engine::netzone_by_name_or_null(const std::string& name) const
{
return netzone_by_name_recursive(get_netzone_root(), name);
}
/** @brief Retrieve the netpoint of the given name (or nullptr if not found) */
-kernel::routing::NetPoint* Engine::netpoint_by_name_or_null(const std::string& name)
+kernel::routing::NetPoint* Engine::netpoint_by_name_or_null(const std::string& name) const
{
auto netp = pimpl->netpoints_.find(name);
return netp == pimpl->netpoints_.end() ? nullptr : netp->second;
}
-std::vector<kernel::routing::NetPoint*> Engine::get_all_netpoints()
+std::vector<kernel::routing::NetPoint*> Engine::get_all_netpoints() const
{
std::vector<kernel::routing::NetPoint*> res;
for (auto const& kv : pimpl->netpoints_)
return *mounts_;
}
-ExecPtr Host::exec_async(double flops)
+ExecPtr Host::exec_async(double flops) const
{
return this_actor::exec_init(flops);
}
-void Host::execute(double flops)
+void Host::execute(double flops) const
{
execute(flops, 1.0 /* priority */);
}
-void Host::execute(double flops, double priority)
+void Host::execute(double flops, double priority) const
{
this_actor::exec_init(flops)->set_priority(1 / priority)->start()->wait();
}
return &mbox->piface_;
}
-bool Mailbox::empty()
+bool Mailbox::empty() const
{
return pimpl_->comm_queue_.empty();
}
-bool Mailbox::listen()
+bool Mailbox::listen() const
{
return not this->empty() || (pimpl_->permanent_receiver_ && not pimpl_->done_comm_queue_.empty());
}
-aid_t Mailbox::listen_from()
+aid_t Mailbox::listen_from() const
{
kernel::activity::CommImplPtr comm = front();
if (comm && comm->src_actor_)
return -1;
}
-bool Mailbox::ready()
+bool Mailbox::ready() const
{
bool comm_ready = false;
if (not pimpl_->comm_queue_.empty()) {
return comm_ready;
}
-kernel::activity::CommImplPtr Mailbox::front()
+kernel::activity::CommImplPtr Mailbox::front() const
{
return pimpl_->comm_queue_.empty() ? nullptr : pimpl_->comm_queue_.front();
}
}
/** @brief get the receiver (process associated to the mailbox) */
-ActorPtr Mailbox::get_receiver()
+ActorPtr Mailbox::get_receiver() const
{
if (pimpl_->permanent_receiver_ == nullptr)
return ActorPtr();