* - Synchronization activities may possibly be connected to no action.
*/
class XBT_PUBLIC Activity {
- friend simgrid::s4u::Comm;
+ friend Comm;
friend XBT_PUBLIC void intrusive_ptr_release(Comm * c);
friend XBT_PUBLIC void intrusive_ptr_add_ref(Comm * c);
- friend simgrid::s4u::Exec;
- friend simgrid::s4u::ExecSeq;
- friend simgrid::s4u::ExecPar;
+
+ friend Exec;
+ friend ExecSeq;
+ friend ExecPar;
friend XBT_PUBLIC void intrusive_ptr_release(Exec * e);
friend XBT_PUBLIC void intrusive_ptr_add_ref(Exec * e);
- friend simgrid::s4u::Io;
+
+ friend Io;
friend XBT_PUBLIC void intrusive_ptr_release(Io* i);
friend XBT_PUBLIC void intrusive_ptr_add_ref(Io* i);
*/
/** @brief Simulation Agent */
-class XBT_PUBLIC Actor : public simgrid::xbt::Extendable<Actor> {
- friend simgrid::s4u::Exec;
- friend simgrid::s4u::Mailbox;
- friend simgrid::kernel::actor::ActorImpl;
- friend simgrid::kernel::activity::MailboxImpl;
+class XBT_PUBLIC Actor : public xbt::Extendable<Actor> {
+ friend Exec;
+ friend Mailbox;
+ friend kernel::actor::ActorImpl;
+ friend kernel::activity::MailboxImpl;
kernel::actor::ActorImpl* const pimpl_;
static ActorPtr self();
/** Signal to others that a new actor has been created **/
- static simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> on_creation;
+ static xbt::signal<void(ActorPtr)> on_creation;
/** Signal to others that an actor has been suspended**/
- static simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> on_suspend;
+ static xbt::signal<void(ActorPtr)> on_suspend;
/** Signal to others that an actor has been resumed **/
- static simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> on_resume;
+ static xbt::signal<void(ActorPtr)> on_resume;
/** Signal to others that an actor is sleeping **/
- static simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> on_sleep;
+ static xbt::signal<void(ActorPtr)> on_sleep;
/** Signal to others that an actor wakes up for a sleep **/
- static simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> on_wake_up;
+ static xbt::signal<void(ActorPtr)> on_wake_up;
/** Signal to others that an actor is going to migrated to another host**/
- static simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> on_migration_start;
+ static xbt::signal<void(ActorPtr)> on_migration_start;
/** Signal to others that an actor is has been migrated to another host **/
- static simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> on_migration_end;
+ static xbt::signal<void(ActorPtr)> on_migration_end;
/** Signal indicating that an actor is about to disappear.
- * This signal is fired for any dying actor, which is mostly useful when
- * designing plugins and extensions. If you want to register to the
- * termination of a given actor, use this_actor::on_exit() instead.*/
- static simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> on_destruction;
+ * This signal is fired for any dying actor, which is mostly useful when designing plugins and extensions. If you
+ * want to register to the termination of a given actor, use this_actor::on_exit() instead.*/
+ static xbt::signal<void(ActorPtr)> on_destruction;
/** Create an actor from a std::function<void()>
*
/** Retrieves the name of that actor as a C string */
const char* get_cname() const;
/** Retrieves the host on which that actor is running */
- s4u::Host* get_host();
+ Host* get_host();
/** Retrieves the actor ID of that actor */
aid_t get_pid() const;
/** Retrieves the actor ID of that actor's creator */
friend XBT_PUBLIC void intrusive_ptr_add_ref(Barrier* barrier);
friend XBT_PUBLIC void intrusive_ptr_release(Barrier* barrier);
};
-}
-} // namespace simgrid::s4u
+} // namespace s4u
+} // namespace simgrid
#endif
public:
friend XBT_PUBLIC void intrusive_ptr_release(simgrid::s4u::Comm * c);
friend XBT_PUBLIC void intrusive_ptr_add_ref(simgrid::s4u::Comm * c);
- friend simgrid::s4u::Mailbox; // Factory of comms
+ friend Mailbox; // Factory of comms
virtual ~Comm();
*/
class XBT_PUBLIC ConditionVariable {
private:
- friend simgrid::kernel::activity::ConditionVariableImpl;
- simgrid::kernel::activity::ConditionVariableImpl* const cond_;
+ friend kernel::activity::ConditionVariableImpl;
+ kernel::activity::ConditionVariableImpl* const cond_;
- explicit ConditionVariable(simgrid::kernel::activity::ConditionVariableImpl* cond) : cond_(cond) {}
+ explicit ConditionVariable(kernel::activity::ConditionVariableImpl* cond) : cond_(cond) {}
public:
ConditionVariable(ConditionVariable const&) = delete;
void notify_all();
};
-}
-} // namespace simgrid::s4u
+} // namespace s4u
+} // namespace simgrid
#endif
template <class F> void register_actor(const std::string& name)
{
- simgrid::simix::register_function(name, [](std::vector<std::string> args) {
- return simgrid::simix::ActorCode([args] {
+ simix::register_function(name, [](std::vector<std::string> args) {
+ return simix::ActorCode([args] {
F code(std::move(args));
code();
});
template <class F> void register_actor(const std::string& name, F code)
{
- simgrid::simix::register_function(name, [code](std::vector<std::string> args) {
- return simgrid::simix::ActorCode([code, args] { code(std::move(args)); });
+ simix::register_function(name, [code](std::vector<std::string> args) {
+ return simix::ActorCode([code, args] { code(std::move(args)); });
});
}
/** @brief Returns the list of all hosts found in the platform */
std::vector<Host*> get_all_hosts();
std::vector<Host*> get_filtered_hosts(const std::function<bool(Host*)>& filter);
- simgrid::s4u::Host* host_by_name(const std::string& name);
- simgrid::s4u::Host* host_by_name_or_null(const std::string& name);
+ Host* host_by_name(const std::string& name);
+ Host* host_by_name_or_null(const std::string& name);
size_t get_link_count();
std::vector<Link*> get_all_links();
std::vector<Link*> get_filtered_links(const std::function<bool(Link*)>& filter);
- simgrid::s4u::Link* link_by_name(const std::string& name);
- simgrid::s4u::Link* link_by_name_or_null(const std::string& name);
+ Link* link_by_name(const std::string& name);
+ Link* link_by_name_or_null(const std::string& name);
size_t get_actor_count();
std::vector<ActorPtr> get_all_actors();
size_t get_storage_count();
std::vector<Storage*> get_all_storages();
- simgrid::s4u::Storage* storage_by_name(const std::string& name);
- simgrid::s4u::Storage* storage_by_name_or_null(const std::string& name);
+ Storage* storage_by_name(const std::string& name);
+ Storage* storage_by_name_or_null(const std::string& name);
- std::vector<simgrid::kernel::routing::NetPoint*> get_all_netpoints();
- simgrid::kernel::routing::NetPoint* netpoint_by_name_or_null(const std::string& name);
+ std::vector<kernel::routing::NetPoint*> get_all_netpoints();
+ kernel::routing::NetPoint* netpoint_by_name_or_null(const std::string& name);
- simgrid::s4u::NetZone* get_netzone_root();
- void set_netzone_root(s4u::NetZone* netzone);
+ NetZone* get_netzone_root();
+ void set_netzone_root(NetZone* netzone);
- simgrid::s4u::NetZone* netzone_by_name_or_null(const std::string& name);
+ NetZone* netzone_by_name_or_null(const std::string& name);
/** @brief Retrieves all netzones of the type indicated by the template argument */
template <class T> std::vector<T*> get_filtered_netzones()
void set_config(const std::string& str);
private:
- simgrid::kernel::EngineImpl* const pimpl;
- static s4u::Engine* instance_;
+ kernel::EngineImpl* const pimpl;
+ static Engine* instance_;
//////////////// Deprecated functions
#ifndef DOXYGEN
}
}
#endif
-}
-} // namespace simgrid::s4u
+} // namespace s4u
+} // namespace simgrid
#endif /* SIMGRID_S4U_ENGINE_HPP */
Exec& operator=(Exec const&) = delete;
#endif
- friend simgrid::s4u::ExecSeq;
- friend simgrid::s4u::ExecPar;
+ friend ExecSeq;
+ friend ExecPar;
friend XBT_PUBLIC void intrusive_ptr_release(Exec* e);
friend XBT_PUBLIC void intrusive_ptr_add_ref(Exec* e);
static xbt::signal<void(ActorPtr)> on_start;
namespace simgrid {
namespace xbt {
-extern template class XBT_PUBLIC Extendable<simgrid::s4u::Host>;
-}
-namespace s4u {
+extern template class XBT_PUBLIC Extendable<s4u::Host>;
+} // namespace xbt
+namespace s4u {
/** @ingroup s4u_api
*
* @tableofcontents
* and actors can retrieve the host on which they run using @ref simgrid::s4u::Host::current() or
* @ref simgrid::s4u::this_actor::get_host().
*/
-class XBT_PUBLIC Host : public simgrid::xbt::Extendable<Host> {
- friend simgrid::vm::VMModel; // Use the pimpl_cpu to compute the VM sharing
- friend simgrid::vm::VirtualMachineImpl; // creates the the pimpl_cpu
+class XBT_PUBLIC Host : public xbt::Extendable<Host> {
+ friend vm::VMModel; // Use the pimpl_cpu to compute the VM sharing
+ friend vm::VirtualMachineImpl; // creates the the pimpl_cpu
public:
explicit Host(const std::string& name);
public:
/*** Called on each newly created host */
- static simgrid::xbt::signal<void(Host&)> on_creation;
+ static xbt::signal<void(Host&)> on_creation;
/*** Called just before destructing a host */
- static simgrid::xbt::signal<void(Host&)> on_destruction;
+ static xbt::signal<void(Host&)> on_destruction;
/*** Called when the machine is turned on or off (called AFTER the change) */
- static simgrid::xbt::signal<void(Host&)> on_state_change;
+ static xbt::signal<void(Host&)> on_state_change;
/*** Called when the speed of the machine is changed (called AFTER the change)
* (either because of a pstate switch or because of an external load event coming from the profile) */
- static simgrid::xbt::signal<void(Host&)> on_speed_change;
+ static xbt::signal<void(Host&)> on_speed_change;
virtual void destroy();
// No copy/move
/** Retrieve a host from its name, or return nullptr */
static Host* by_name_or_null(const std::string& name);
/** Retrieve a host from its name, or die */
- static s4u::Host* by_name(const std::string& name);
+ static Host* by_name(const std::string& name);
/** Retrieves the host on which the running actor is located */
- static s4u::Host* current();
+ static Host* current();
/** Retrieves the name of that host as a C++ string */
- simgrid::xbt::string const& get_name() const { return name_; }
+ xbt::string const& get_name() const { return name_; }
/** Retrieves the name of that host as a C string */
const char* get_cname() const { return name_.c_str(); }
/** Turns that host on if it was previously off
*
- * This call does nothing if the host is already on. If it was off, all actors which were
- * marked 'autorestart' on that host will be restarted automatically (note that this may differ
- * from the actors that were initially running on the host).
+ * This call does nothing if the host is already on. If it was off, all actors which were marked 'autorestart' on that
+ * host will be restarted automatically (note that this may differ from the actors that were initially running on the
+ * host).
*
- * All other Host's properties are left unchanged; in particular, the pstate is left
- * unchanged and not reset to its initial value.
+ * All other Host's properties are left unchanged; in particular, the pstate is left unchanged and not reset to its
+ * initial value.
*/
void turn_on();
/** Turns that host off. All actors are forcefully stopped. */
#endif /* !DOXYGEN */
private:
- simgrid::xbt::string name_ {"noname"};
+ xbt::string name_{"noname"};
std::unordered_map<std::string, Storage*>* mounts_ = nullptr; // caching
public:
kernel::routing::NetPoint* pimpl_netpoint = nullptr;
#endif
};
-}
-} // namespace simgrid::s4u
+} // namespace s4u
+} // namespace simgrid
extern int USER_HOST_LEVEL;
public:
friend XBT_PUBLIC void intrusive_ptr_release(simgrid::s4u::Io* i);
friend XBT_PUBLIC void intrusive_ptr_add_ref(simgrid::s4u::Io* i);
- friend simgrid::s4u::Storage; // Factory of IOs
+ friend Storage; // Factory of IOs
~Io() = default;
#ifndef DOXYGEN
XBT_ATTRIB_DEPRECATED_v324("Please use Io::wait_for()") void wait(double t) override { wait_for(t); }
#endif
+};
-}; // class
} // namespace s4u
} // namespace simgrid
namespace simgrid {
namespace s4u {
/** @brief A Link represents the network facilities between [hosts](@ref simgrid::s4u::Host) */
-class XBT_PUBLIC Link : public simgrid::xbt::Extendable<Link> {
- friend simgrid::kernel::resource::LinkImpl;
+class XBT_PUBLIC Link : public xbt::Extendable<Link> {
+ friend kernel::resource::LinkImpl;
// Links are created from the NetZone, and destroyed by their private implementation when the simulation ends
explicit Link(kernel::resource::LinkImpl* pimpl) : pimpl_(pimpl) {}
/* The signals */
/** @brief Callback signal fired when a new Link is created */
- static simgrid::xbt::signal<void(s4u::Link&)> on_creation;
+ static xbt::signal<void(Link&)> on_creation;
/** @brief Callback signal fired when a Link is destroyed */
- static simgrid::xbt::signal<void(s4u::Link&)> on_destruction;
+ static xbt::signal<void(Link&)> on_destruction;
/** @brief Callback signal fired when the state of a Link changes (when it is turned on or off) */
- static simgrid::xbt::signal<void(s4u::Link&)> on_state_change;
+ static xbt::signal<void(Link&)> on_state_change;
/** @brief Callback signal fired when the bandwidth of a Link changes */
- static simgrid::xbt::signal<void(s4u::Link&)> on_bandwidth_change;
+ static xbt::signal<void(Link&)> on_bandwidth_change;
/** @brief Callback signal fired when a communication starts */
- static simgrid::xbt::signal<void(kernel::resource::NetworkAction*, s4u::Host* src, s4u::Host* dst)> on_communicate;
+ static xbt::signal<void(kernel::resource::NetworkAction*, Host* src, Host* dst)> on_communicate;
/** @brief Callback signal fired when a communication changes it state (ready/done/cancel) */
- static simgrid::xbt::signal<void(kernel::resource::NetworkAction*, kernel::resource::Action::State)>
+ static xbt::signal<void(kernel::resource::NetworkAction*, kernel::resource::Action::State)>
on_communication_state_change;
#ifndef DOXYGEN
/** @deprecated */
XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_state_profile()") void setStateTrace(
- simgrid::kernel::profile::Profile* profile) {set_state_profile(profile); }
+ kernel::profile::Profile* profile)
+ {
+ set_state_profile(profile);
+ }
/** @deprecated */
XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_bandwidth_profile()") void setBandwidthTrace(
- simgrid::kernel::profile::Profile* profile) { set_bandwidth_profile(profile); }
+ kernel::profile::Profile* profile)
+ {
+ set_bandwidth_profile(profile);
+ }
/** @deprecated */
XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_latency_profile()") void setLatencyTrace(
- simgrid::kernel::profile::Profile* profile) { set_latency_profile(profile); }
+ kernel::profile::Profile* profile)
+ {
+ set_latency_profile(profile);
+ }
#endif
};
-}
-}
+} // namespace s4u
+} // namespace simgrid
#endif /* SURF_NETWORK_INTERFACE_HPP_ */
/** @brief Mailboxes: Network rendez-vous points. */
class XBT_PUBLIC Mailbox {
- friend simgrid::s4u::Comm;
- friend simgrid::kernel::activity::MailboxImpl;
+ friend Comm;
+ friend kernel::activity::MailboxImpl;
- simgrid::kernel::activity::MailboxImpl* const pimpl_;
+ kernel::activity::MailboxImpl* const pimpl_;
explicit Mailbox(kernel::activity::MailboxImpl * mbox) : pimpl_(mbox) {}
kernel::activity::MailboxImpl* get_impl() { return pimpl_; }
/** @brief Retrieves the name of that mailbox as a C++ string */
- const simgrid::xbt::string& get_name() const;
+ const xbt::string& get_name() const;
/** @brief Retrieves the name of that mailbox as a C string */
const char* get_cname() const;
/** @deprecated Mailbox::get_receiver() */
XBT_ATTRIB_DEPRECATED_v323("Please use Mailbox::get_receiver()") ActorPtr getReceiver() { return get_receiver(); }
/** @deprecated Mailbox::get_name() */
- XBT_ATTRIB_DEPRECATED_v323("Please use Mailbox::get_name()") const simgrid::xbt::string& getName() const
- {
- return get_name();
- }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Mailbox::get_name()") const xbt::string& getName() const { return get_name(); }
/** @deprecated Mailbox::get_cname() */
XBT_ATTRIB_DEPRECATED_v323("Please use Mailbox::get_cname()") const char* getCname() const { return get_cname(); }
/** @deprecated Mailbox::get_impl() */
#endif
};
-}} // namespace simgrid::s4u
+} // namespace s4u
+} // namespace simgrid
#endif /* SIMGRID_S4U_MAILBOX_HPP */
*
*/
class XBT_PUBLIC Mutex {
- friend simgrid::s4u::ConditionVariable;
- friend simgrid::kernel::activity::MutexImpl;
+ friend ConditionVariable;
+ friend kernel::activity::MutexImpl;
- simgrid::kernel::activity::MutexImpl* const pimpl_;
- explicit Mutex(simgrid::kernel::activity::MutexImpl* mutex) : pimpl_(mutex) {}
+ kernel::activity::MutexImpl* const pimpl_;
+ explicit Mutex(kernel::activity::MutexImpl* mutex) : pimpl_(mutex) {}
/* refcounting */
friend XBT_PUBLIC void intrusive_ptr_add_ref(Mutex* mutex);
friend XBT_PUBLIC void intrusive_ptr_release(Mutex* mutex);
#endif
};
-}} // namespace simgrid::s4u
+} // namespace s4u
+} // namespace simgrid
#endif /* SIMGRID_S4U_MUTEX_HPP */
*/
class XBT_PUBLIC NetZone {
protected:
- friend simgrid::kernel::routing::NetZoneImpl;
+ friend kernel::routing::NetZoneImpl;
explicit NetZone(kernel::routing::NetZoneImpl* impl);
~NetZone();
std::vector<kernel::resource::LinkImpl*>& link_list, bool symmetrical);
/*** Called on each newly created regular route (not on bypass routes) */
- static simgrid::xbt::signal<void(bool symmetrical, kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
- kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
- std::vector<kernel::resource::LinkImpl*>& link_list)>
+ static xbt::signal<void(bool symmetrical, kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
+ kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
+ std::vector<kernel::resource::LinkImpl*>& link_list)>
on_route_creation;
- static simgrid::xbt::signal<void(NetZone&)> on_creation;
- static simgrid::xbt::signal<void(NetZone&)> on_seal;
+ static xbt::signal<void(NetZone&)> on_creation;
+ static xbt::signal<void(NetZone&)> on_seal;
#ifndef DOXYGEN
// Deprecation wrappers
/** @deprecated NetZone::add_route() */
XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::add_route()") void addRoute(
kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src,
- kernel::routing::NetPoint* gw_dst, std::vector<simgrid::kernel::resource::LinkImpl*>& link_list, bool symmetrical)
+ kernel::routing::NetPoint* gw_dst, std::vector<kernel::resource::LinkImpl*>& link_list, bool symmetrical)
{
add_route(src, dst, gw_src, gw_dst, link_list, symmetrical);
}
/** @deprecated NetZone::add_bypass_route() */
XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::add_bypass_route()") void addBypassRoute(
kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src,
- kernel::routing::NetPoint* gw_dst, std::vector<simgrid::kernel::resource::LinkImpl*>& link_list, bool symmetrical)
+ kernel::routing::NetPoint* gw_dst, std::vector<kernel::resource::LinkImpl*>& link_list, bool symmetrical)
{
add_bypass_route(src, dst, gw_src, gw_dst, link_list, symmetrical);
}
}
#endif
};
-}
-}; // Namespace simgrid::s4u
+
+} // namespace s4u
+} // namespace simgrid
#endif /* SIMGRID_S4U_NETZONE_HPP */
int would_block();
};
-}} // namespace simgrid::s4u
+} // namespace s4u
+} // namespace simgrid
#endif /* SIMGRID_S4U_SEMAPHORE_HPP */
* only computes the time taken by the corresponding data movement.
*/
-class XBT_PUBLIC Storage : public simgrid::xbt::Extendable<Storage> {
+class XBT_PUBLIC Storage : public xbt::Extendable<Storage> {
friend Engine;
friend Io;
friend kernel::resource::StorageImpl;
virtual ~Storage() = default;
public:
/** @brief Callback signal fired when a new Storage is created */
- static xbt::signal<void(s4u::Storage&)> on_creation;
+ static xbt::signal<void(Storage&)> on_creation;
/** @brief Callback signal fired when a Storage is destroyed */
- static xbt::signal<void(s4u::Storage&)> on_destruction;
+ static xbt::signal<void(Storage&)> on_destruction;
/** @brief Callback signal fired when a Storage's state changes */
- static xbt::signal<void(s4u::Storage&)> on_state_change;
+ static xbt::signal<void(Storage&)> on_state_change;
/** Retrieve a Storage by its name. It must exist in the platform file */
static Storage* by_name(const std::string& name);
void* userdata_ = nullptr;
};
-} /* namespace s4u */
-} /* namespace simgrid */
+} // namespace s4u
+} // namespace simgrid
#endif /* INCLUDE_SIMGRID_S4U_STORAGE_HPP_ */
*
*/
class XBT_PUBLIC VirtualMachine : public s4u::Host {
- simgrid::vm::VirtualMachineImpl* const pimpl_vm_;
+ vm::VirtualMachineImpl* const pimpl_vm_;
virtual ~VirtualMachine();
public:
- explicit VirtualMachine(const std::string& name, s4u::Host* physical_host, int core_amount);
- explicit VirtualMachine(const std::string& name, s4u::Host* physical_host, int core_amount, size_t ramsize);
+ explicit VirtualMachine(const std::string& name, Host* physical_host, int core_amount);
+ explicit VirtualMachine(const std::string& name, Host* physical_host, int core_amount, size_t ramsize);
// No copy/move
VirtualMachine(VirtualMachine const&) = delete;
DESTROYED
};
- simgrid::vm::VirtualMachineImpl* get_impl() { return pimpl_vm_; }
+ vm::VirtualMachineImpl* get_impl() { return pimpl_vm_; }
void start();
void suspend();
void resume();
void shutdown();
void destroy();
- simgrid::s4u::Host* get_pm();
- void set_pm(simgrid::s4u::Host* pm);
+ Host* get_pm();
+ void set_pm(Host* pm);
size_t get_ramsize();
void set_ramsize(size_t ramsize);
void set_bound(double bound);
VirtualMachine::state get_state();
- static simgrid::xbt::signal<void(VirtualMachine&)> on_start;
- static simgrid::xbt::signal<void(VirtualMachine&)> on_started;
- static simgrid::xbt::signal<void(VirtualMachine&)> on_shutdown;
- static simgrid::xbt::signal<void(VirtualMachine&)> on_suspend;
- static simgrid::xbt::signal<void(VirtualMachine&)> on_resume;
- static simgrid::xbt::signal<void(VirtualMachine&)> on_migration_start;
- static simgrid::xbt::signal<void(VirtualMachine&)> on_migration_end;
+ static xbt::signal<void(VirtualMachine&)> on_start;
+ static xbt::signal<void(VirtualMachine&)> on_started;
+ static xbt::signal<void(VirtualMachine&)> on_shutdown;
+ static xbt::signal<void(VirtualMachine&)> on_suspend;
+ static xbt::signal<void(VirtualMachine&)> on_resume;
+ static xbt::signal<void(VirtualMachine&)> on_migration_start;
+ static xbt::signal<void(VirtualMachine&)> on_migration_end;
#ifndef DOXYGEN
// Deprecated methods
return get_state();
}
/** @deprecated See VirtualMachine::get_impl() */
- XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::get_impl()") simgrid::vm::VirtualMachineImpl* getImpl()
+ XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::get_impl()") vm::VirtualMachineImpl* getImpl()
{
return pimpl_vm_;
}
/** @deprecated See VirtualMachine::get_pm() */
- XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::get_pm()") simgrid::s4u::Host* getPm() { return get_pm(); }
+ XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::get_pm()") Host* getPm() { return get_pm(); }
/** @deprecated See VirtualMachine::set_pm() */
- XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::set_pm()") void setPm(simgrid::s4u::Host* pm) { set_pm(pm); }
+ XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::set_pm()") void setPm(Host* pm) { set_pm(pm); }
/** @deprecated See VirtualMachine::get_ramsize() */
XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::get_ramsize()") size_t getRamsize() { return get_ramsize(); }
/** @deprecated See VirtualMachine::set_ramsize() */
XBT_ATTRIB_DEPRECATED_v323("Please use VirtualMachine::set_bound()") void setBound(double bound) { set_bound(bound); }
#endif
};
-}
-} // namespace simgrid::s4u
+} // namespace s4u
+} // namespace simgrid
#endif
namespace simgrid {
namespace s4u {
-simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Actor::on_creation;
-simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Actor::on_suspend;
-simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Actor::on_resume;
-simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Actor::on_sleep;
-simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Actor::on_wake_up;
-simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Actor::on_migration_start;
-simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Actor::on_migration_end;
-simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Actor::on_destruction;
+xbt::signal<void(ActorPtr)> s4u::Actor::on_creation;
+xbt::signal<void(ActorPtr)> s4u::Actor::on_suspend;
+xbt::signal<void(ActorPtr)> s4u::Actor::on_resume;
+xbt::signal<void(ActorPtr)> s4u::Actor::on_sleep;
+xbt::signal<void(ActorPtr)> s4u::Actor::on_wake_up;
+xbt::signal<void(ActorPtr)> s4u::Actor::on_migration_start;
+xbt::signal<void(ActorPtr)> s4u::Actor::on_migration_end;
+xbt::signal<void(ActorPtr)> s4u::Actor::on_destruction;
// ***** Actor creation *****
ActorPtr Actor::self()
{
- smx_context_t self_context = simgrid::kernel::context::Context::self();
+ smx_context_t self_context = kernel::context::Context::self();
if (self_context == nullptr)
- return simgrid::s4u::ActorPtr();
+ return ActorPtr();
return self_context->get_actor()->iface();
}
ActorPtr Actor::create(const std::string& name, s4u::Host* host, const std::string& function,
std::vector<std::string> args)
{
- simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
+ simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
return create(name, host, factory(std::move(args)));
}
void Actor::set_auto_restart(bool autorestart)
{
- simgrid::simix::simcall([this, autorestart]() {
+ simix::simcall([this, autorestart]() {
xbt_assert(autorestart && not pimpl_->has_to_auto_restart()); // FIXME: handle all cases
pimpl_->set_auto_restart(autorestart);
- simgrid::kernel::actor::ProcessArg* arg = new simgrid::kernel::actor::ProcessArg(pimpl_->get_host(), pimpl_);
+ kernel::actor::ProcessArg* arg = new kernel::actor::ProcessArg(pimpl_->get_host(), pimpl_);
XBT_DEBUG("Adding Process %s to the actors_at_boot_ list of Host %s", arg->name.c_str(), arg->host->get_cname());
pimpl_->get_host()->pimpl_->actors_at_boot_.emplace_back(arg);
});
void* data) /* deprecated: cleanup SIMIX_process_on_exit: change prototype of second parameter and
remove the last one */
{
- simgrid::simix::simcall([this, fun, data] { SIMIX_process_on_exit(pimpl_, fun, data); });
+ simix::simcall([this, fun, data] { SIMIX_process_on_exit(pimpl_, fun, data); });
}
void Actor::on_exit(const std::function<void(int, void*)>& fun, void* data) /* deprecated */
void Actor::on_exit(const std::function<void(bool /*failed*/)>& fun)
{
- simgrid::simix::simcall(
+ simix::simcall(
[this, fun] { SIMIX_process_on_exit(pimpl_, [fun](int a, void* /*data*/) { fun(a != 0); }, nullptr); });
}
{
s4u::Actor::on_migration_start(this);
- simgrid::simix::simcall([this, new_host]() {
+ simix::simcall([this, new_host]() {
if (pimpl_->waiting_synchro != nullptr) {
// The actor is blocked on an activity. If it's an exec, migrate it too.
// FIXME: implement the migration of other kind of activities
- simgrid::kernel::activity::ExecImplPtr exec =
- boost::dynamic_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_->waiting_synchro);
+ kernel::activity::ExecImplPtr exec =
+ boost::dynamic_pointer_cast<kernel::activity::ExecImpl>(pimpl_->waiting_synchro);
xbt_assert(exec.get() != nullptr, "We can only migrate blocked actors when they are blocked on executions.");
exec->migrate(new_host);
}
void Actor::daemonize()
{
- simgrid::simix::simcall([this]() { pimpl_->daemonize(); });
+ simix::simcall([this]() { pimpl_->daemonize(); });
}
bool Actor::is_daemon() const
void Actor::resume()
{
- simgrid::simix::simcall([this] { pimpl_->resume(); });
+ simix::simcall([this] { pimpl_->resume(); });
s4u::Actor::on_resume(this);
}
bool Actor::is_suspended()
{
- return simgrid::simix::simcall([this] { return pimpl_->is_suspended(); });
+ return simix::simcall([this] { return pimpl_->is_suspended(); });
}
void Actor::set_kill_time(double kill_time)
{
- simgrid::simix::simcall([this, kill_time] { pimpl_->set_kill_time(kill_time); });
+ simix::simcall([this, kill_time] { pimpl_->set_kill_time(kill_time); });
}
/** @brief Get the kill time of an actor(or 0 if unset). */
void Actor::kill(aid_t pid) // deprecated
{
- smx_actor_t killer = SIMIX_process_self();
- smx_actor_t victim = SIMIX_process_from_PID(pid);
+ kernel::actor::ActorImpl* killer = SIMIX_process_self();
+ kernel::actor::ActorImpl* victim = SIMIX_process_from_PID(pid);
if (victim != nullptr) {
- simgrid::simix::simcall([killer, victim] { killer->kill(victim); });
+ simix::simcall([killer, victim] { killer->kill(victim); });
} else {
std::ostringstream oss;
oss << "kill: (" << pid << ") - No such actor" << std::endl;
void Actor::kill()
{
- smx_actor_t process = SIMIX_process_self();
- simgrid::simix::simcall([this, process] {
+ kernel::actor::ActorImpl* process = SIMIX_process_self();
+ simix::simcall([this, process] {
if (pimpl_ == simix_global->maestro_process)
pimpl_->exit();
else
});
}
-smx_actor_t Actor::get_impl()
+kernel::actor::ActorImpl* Actor::get_impl()
{
return pimpl_;
}
ActorPtr Actor::by_pid(aid_t pid)
{
- smx_actor_t process = SIMIX_process_from_PID(pid);
+ kernel::actor::ActorImpl* process = SIMIX_process_from_PID(pid);
if (process != nullptr)
return process->iface();
else
void Actor::kill_all()
{
- smx_actor_t self = SIMIX_process_self();
- simgrid::simix::simcall([self] { self->kill_all(); });
+ kernel::actor::ActorImpl* self = SIMIX_process_self();
+ simix::simcall([self] { self->kill_all(); });
}
std::unordered_map<std::string, std::string>* Actor::get_properties()
{
- return simgrid::simix::simcall([this] { return this->pimpl_->get_properties(); });
+ return simix::simcall([this] { return this->pimpl_->get_properties(); });
}
/** Retrieve the property value (or nullptr if not set) */
const char* Actor::get_property(const std::string& key)
{
- return simgrid::simix::simcall([this, &key] { return pimpl_->get_property(key); });
+ return simix::simcall([this, &key] { return pimpl_->get_property(key); });
}
void Actor::set_property(const std::string& key, const std::string& value)
{
- simgrid::simix::simcall([this, &key, &value] { pimpl_->set_property(key, value); });
+ simix::simcall([this, &key, &value] { pimpl_->set_property(key, value); });
}
Actor* Actor::restart()
{
- return simgrid::simix::simcall([this]() { return pimpl_->restart(); });
+ return simix::simcall([this]() { return pimpl_->restart(); });
}
// ***** this_actor *****
*/
bool is_maestro()
{
- smx_actor_t process = SIMIX_process_self();
+ kernel::actor::ActorImpl* process = SIMIX_process_self();
return process == nullptr || process == simix_global->maestro_process;
}
void sleep_for(double duration)
{
if (duration > 0) {
- smx_actor_t actor = SIMIX_process_self();
- simgrid::s4u::Actor::on_sleep(actor->iface());
+ kernel::actor::ActorImpl* actor = SIMIX_process_self();
+ Actor::on_sleep(actor->iface());
simcall_process_sleep(duration);
- simgrid::s4u::Actor::on_wake_up(actor->iface());
+ Actor::on_wake_up(actor->iface());
}
}
void yield()
{
- simgrid::simix::simcall([] { /* do nothing*/ });
+ simix::simcall([] { /* do nothing*/ });
}
XBT_PUBLIC void sleep_until(double timeout)
"bytes_amounts must be a matrix of size host_count * host_count (%zu*%zu), but it's of size %zu.",
hosts.size(), hosts.size(), flops_amounts.size());
/* Check that we are not mixing VMs and PMs in the parallel task */
- bool is_a_vm = (nullptr != dynamic_cast<simgrid::s4u::VirtualMachine*>(hosts.front()));
+ bool is_a_vm = (nullptr != dynamic_cast<VirtualMachine*>(hosts.front()));
xbt_assert(std::all_of(hosts.begin(), hosts.end(),
[is_a_vm](s4u::Host* elm) {
- bool tmp_is_a_vm = (nullptr != dynamic_cast<simgrid::s4u::VirtualMachine*>(elm));
+ bool tmp_is_a_vm = (nullptr != dynamic_cast<VirtualMachine*>(elm));
return is_a_vm == tmp_is_a_vm;
}),
"parallel_execute: mixing VMs and PMs is not supported (yet).");
void suspend()
{
- smx_actor_t actor = SIMIX_process_self();
- simgrid::s4u::Actor::on_suspend(actor->iface());
+ kernel::actor::ActorImpl* actor = SIMIX_process_self();
+ Actor::on_suspend(actor->iface());
simcall_process_suspend(actor);
}
void resume()
{
- smx_actor_t process = SIMIX_process_self();
- simgrid::simix::simcall([process] { process->resume(); });
- simgrid::s4u::Actor::on_resume(process->iface());
+ kernel::actor::ActorImpl* self = SIMIX_process_self();
+ simix::simcall([self] { self->resume(); });
+ Actor::on_resume(self->iface());
}
void exit()
{
- smx_actor_t actor = SIMIX_process_self();
- simgrid::simix::simcall([actor] { actor->exit(); });
+ kernel::actor::ActorImpl* self = SIMIX_process_self();
+ simgrid::simix::simcall([self] { self->exit(); });
}
void on_exit(const std::function<void(bool)>& fun)
namespace simgrid {
namespace s4u {
-simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Comm::on_sender_start;
-simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Comm::on_receiver_start;
-simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Comm::on_completion;
+xbt::signal<void(ActorPtr)> Comm::on_sender_start;
+xbt::signal<void(ActorPtr)> Comm::on_receiver_start;
+xbt::signal<void(ActorPtr)> Comm::on_completion;
Comm::~Comm()
{
int Comm::wait_any_for(std::vector<CommPtr>* comms, double timeout)
{
- std::unique_ptr<simgrid::kernel::activity::CommImpl* []> rcomms(
- new simgrid::kernel::activity::CommImpl*[comms->size()]);
- std::transform(begin(*comms), end(*comms), rcomms.get(), [](const CommPtr& comm) {
- return static_cast<simgrid::kernel::activity::CommImpl*>(comm->pimpl_.get());
- });
+ std::unique_ptr<kernel::activity::CommImpl* []> rcomms(new kernel::activity::CommImpl*[comms->size()]);
+ std::transform(begin(*comms), end(*comms), rcomms.get(),
+ [](const CommPtr& comm) { return static_cast<kernel::activity::CommImpl*>(comm->pimpl_.get()); });
return simcall_comm_waitany(rcomms.get(), comms->size(), timeout);
}
}
int Comm::test_any(std::vector<CommPtr>* comms)
{
- std::unique_ptr<simgrid::kernel::activity::CommImpl* []> rcomms(
- new simgrid::kernel::activity::CommImpl*[comms->size()]);
- std::transform(begin(*comms), end(*comms), rcomms.get(), [](const CommPtr& comm) {
- return static_cast<simgrid::kernel::activity::CommImpl*>(comm->pimpl_.get());
- });
+ std::unique_ptr<kernel::activity::CommImpl* []> rcomms(new kernel::activity::CommImpl*[comms->size()]);
+ std::transform(begin(*comms), end(*comms), rcomms.get(),
+ [](const CommPtr& comm) { return static_cast<kernel::activity::CommImpl*>(comm->pimpl_.get()); });
return simcall_comm_testany(rcomms.get(), comms->size());
}
Comm* Comm::cancel()
{
- simgrid::simix::simcall([this] {
+ simix::simcall([this] {
if (pimpl_)
boost::static_pointer_cast<kernel::activity::CommImpl>(pimpl_)->cancel();
});
Engine::Engine(int* argc, char** argv) : pimpl(new kernel::EngineImpl())
{
- xbt_assert(s4u::Engine::instance_ == nullptr,
- "It is currently forbidden to create more than one instance of s4u::Engine");
+ xbt_assert(Engine::instance_ == nullptr, "It is currently forbidden to create more than one instance of s4u::Engine");
TRACE_global_init();
SIMIX_global_init(argc, argv);
- s4u::Engine::instance_ = this;
+ Engine::instance_ = this;
}
Engine::~Engine()
{
delete pimpl;
- s4u::Engine::instance_ = nullptr;
+ Engine::instance_ = nullptr;
}
/** @brief Retrieve the engine singleton */
Engine* Engine::get_instance()
{
- if (s4u::Engine::instance_ == nullptr) {
+ if (Engine::instance_ == nullptr) {
auto e = new Engine(0, nullptr);
- xbt_assert(s4u::Engine::instance_ == e);
+ xbt_assert(Engine::instance_ == e);
}
- return s4u::Engine::instance_;
+ return Engine::instance_;
}
void Engine::shutdown()
{
- delete s4u::Engine::instance_;
- s4u::Engine::instance_ = nullptr;
+ delete Engine::instance_;
+ Engine::instance_ = nullptr;
}
double Engine::get_clock()
return hosts;
}
-void Engine::host_register(const std::string& name, simgrid::s4u::Host* host)
+void Engine::host_register(const std::string& name, Host* host)
{
pimpl->hosts_[name] = host;
}
*
* @throw std::invalid_argument if the searched host does not exist.
*/
-simgrid::s4u::Host* Engine::host_by_name(const std::string& name)
+Host* Engine::host_by_name(const std::string& name)
{
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) */
-simgrid::s4u::Host* Engine::host_by_name_or_null(const std::string& name)
+Host* Engine::host_by_name_or_null(const std::string& name)
{
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.
*/
-simgrid::s4u::Link* Engine::link_by_name(const std::string& name)
+Link* Engine::link_by_name(const std::string& name)
{
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) */
-simgrid::s4u::Link* Engine::link_by_name_or_null(const std::string& name)
+Link* Engine::link_by_name_or_null(const std::string& name)
{
auto link = pimpl->links_.find(name);
return link == pimpl->links_.end() ? nullptr : link->second;
}
-void Engine::link_register(const std::string& name, simgrid::s4u::Link* link)
+void Engine::link_register(const std::string& name, Link* link)
{
pimpl->links_[name] = link;
}
*
* @throw std::invalid_argument if the searched storage does not exist.
*/
-simgrid::s4u::Storage* Engine::storage_by_name(const std::string& name)
+Storage* Engine::storage_by_name(const std::string& name)
{
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) */
-simgrid::s4u::Storage* Engine::storage_by_name_or_null(const std::string& name)
+Storage* Engine::storage_by_name_or_null(const std::string& name)
{
auto storage = pimpl->storages_.find(name);
return storage == pimpl->storages_.end() ? nullptr : storage->second;
}
-void Engine::storage_register(const std::string& name, simgrid::s4u::Storage* storage)
+void Engine::storage_register(const std::string& name, Storage* storage)
{
pimpl->storages_[name] = storage;
}
pimpl->netzone_root_ = netzone->get_impl();
}
-static s4u::NetZone* netzone_by_name_recursive(s4u::NetZone* current, const std::string& name)
+static NetZone* netzone_by_name_recursive(NetZone* current, const std::string& name)
{
if (current->get_name() == name)
return current;
for (auto const& elem : current->get_children()) {
- simgrid::s4u::NetZone* tmp = netzone_by_name_recursive(elem, name);
+ NetZone* tmp = netzone_by_name_recursive(elem, name);
if (tmp != nullptr) {
return tmp;
}
}
/** @brief Retrieve the netpoint of the given name (or nullptr if not found) */
-simgrid::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)
{
auto netp = pimpl->netpoints_.find(name);
return netp == pimpl->netpoints_.end() ? nullptr : netp->second;
}
/** @brief Fill the provided vector with all existing netpoints */
-void Engine::getNetpointList(std::vector<simgrid::kernel::routing::NetPoint*>* list)
+void Engine::getNetpointList(std::vector<kernel::routing::NetPoint*>* list)
{
for (auto const& kv : pimpl->netpoints_)
list->push_back(kv.second);
}
-std::vector<simgrid::kernel::routing::NetPoint*> Engine::get_all_netpoints()
+std::vector<kernel::routing::NetPoint*> Engine::get_all_netpoints()
{
- std::vector<simgrid::kernel::routing::NetPoint*> res;
+ std::vector<kernel::routing::NetPoint*> res;
for (auto const& kv : pimpl->netpoints_)
res.push_back(kv.second);
return res;
}
/** @brief Register a new netpoint to the system */
-void Engine::netpoint_register(simgrid::kernel::routing::NetPoint* point)
+void Engine::netpoint_register(kernel::routing::NetPoint* point)
{
// simgrid::simix::simcall([&]{ FIXME: this segfaults in set_thread
pimpl->netpoints_[point->get_name()] = point;
// });
}
+
/** @brief Unregister a given netpoint */
-void Engine::netpoint_unregister(simgrid::kernel::routing::NetPoint* point)
+void Engine::netpoint_unregister(kernel::routing::NetPoint* point)
{
- simgrid::simix::simcall([this, point] {
+ simix::simcall([this, point] {
pimpl->netpoints_.erase(point->get_name());
delete point;
});
}
void Engine::set_config(const std::string& str)
{
- simgrid::config::set_parse(str);
+ config::set_parse(str);
}
} // namespace s4u
} // namespace simgrid
namespace simgrid {
namespace s4u {
-simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Exec::on_start;
-simgrid::xbt::signal<void(simgrid::s4u::ActorPtr)> s4u::Exec::on_completion;
+xbt::signal<void(ActorPtr)> Exec::on_start;
+xbt::signal<void(ActorPtr)> Exec::on_completion;
Exec::Exec()
{
Exec* Exec::cancel()
{
- simgrid::simix::simcall([this] { boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->cancel(); });
+ simix::simcall([this] { boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->cancel(); });
state_ = State::CANCELED;
return this;
}
}
double ExecPar::get_remaining_ratio()
{
- return simgrid::simix::simcall([this]() {
- return boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_)->get_par_remaining_ratio();
- });
+ return simix::simcall(
+ [this]() { return boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->get_par_remaining_ratio(); });
}
double ExecPar::get_remaining()
int USER_HOST_LEVEL = -1;
namespace simgrid {
-
namespace xbt {
-template class Extendable<simgrid::s4u::Host>;
-}
+template class Extendable<s4u::Host>;
+} // namespace xbt
namespace s4u {
-simgrid::xbt::signal<void(Host&)> Host::on_creation;
-simgrid::xbt::signal<void(Host&)> Host::on_destruction;
-simgrid::xbt::signal<void(Host&)> Host::on_state_change;
-simgrid::xbt::signal<void(Host&)> Host::on_speed_change;
+xbt::signal<void(Host&)> Host::on_creation;
+xbt::signal<void(Host&)> Host::on_destruction;
+xbt::signal<void(Host&)> Host::on_state_change;
+xbt::signal<void(Host&)> Host::on_speed_change;
Host::Host(const std::string& name) : name_(name)
{
xbt_assert(Host::by_name_or_null(name_) == nullptr, "Refusing to create a second host named '%s'.", get_cname());
Engine::get_instance()->host_register(name_, this);
- new simgrid::surf::HostImpl(this);
+ new surf::HostImpl(this);
}
Host::~Host()
delete pimpl_;
if (pimpl_netpoint != nullptr) // not removed yet by a children class
- simgrid::s4u::Engine::get_instance()->netpoint_unregister(pimpl_netpoint);
+ Engine::get_instance()->netpoint_unregister(pimpl_netpoint);
delete pimpl_cpu;
delete mounts_;
}
*
* Don't delete directly a host, call h->destroy() instead.
*
- * This is cumbersome but this is the simplest solution to ensure that the
- * onDestruction() callback receives a valid object (because of the destructor
- * order in a class hierarchy).
+ * This is cumbersome but this is the simplest solution to ensure that the onDestruction() callback receives a valid
+ * object (because of the destructor order in a class hierarchy).
*/
void Host::destroy()
{
Host* Host::current()
{
- smx_actor_t self = SIMIX_process_self();
+ kernel::actor::ActorImpl* self = SIMIX_process_self();
if (self == nullptr)
xbt_die("Cannot call Host::current() from the maestro context");
return self->get_host();
void Host::turn_on()
{
if (not is_on()) {
- simgrid::simix::simcall([this] {
+ simix::simcall([this] {
this->pimpl_cpu->turn_on();
this->pimpl_->turn_on();
on_state_change(*this);
void Host::turn_off()
{
if (is_on()) {
- simgrid::simix::simcall([this] {
+ simix::simcall([this] {
this->pimpl_cpu->turn_off();
this->pimpl_->turn_off();
/** @brief Just like Host::routeTo, but filling an array of link implementations */
void Host::route_to(Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency)
{
- simgrid::kernel::routing::NetZoneImpl::get_global_route(pimpl_netpoint, dest->pimpl_netpoint, links, latency);
+ kernel::routing::NetZoneImpl::get_global_route(pimpl_netpoint, dest->pimpl_netpoint, links, latency);
if (XBT_LOG_ISENABLED(surf_route, xbt_log_priority_debug)) {
XBT_CDEBUG(surf_route, "Route from '%s' to '%s' (latency: %f):", get_cname(), dest->get_cname(),
(latency == nullptr ? -1 : *latency));
/** Get the properties assigned to a host */
std::unordered_map<std::string, std::string>* Host::get_properties()
{
- return simgrid::simix::simcall([this] { return this->pimpl_->get_properties(); });
+ return simix::simcall([this] { return this->pimpl_->get_properties(); });
}
/** Retrieve the property value (or nullptr if not set) */
void Host::set_property(const std::string& key, const std::string& value)
{
- simgrid::simix::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
+ simix::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
}
/** Specify a profile turning the host on and off according to a exhaustive list or a stochastic law.
* The profile must contain boolean values. */
void Host::set_state_profile(kernel::profile::Profile* p)
{
- return simgrid::simix::simcall([this, p] { pimpl_cpu->set_state_profile(p); });
+ return simix::simcall([this, p] { pimpl_cpu->set_state_profile(p); });
}
/** Specify a profile modeling the external load according to a exhaustive list or a stochastic law.
*
*/
void Host::set_speed_profile(kernel::profile::Profile* p)
{
- return simgrid::simix::simcall([this, p] { pimpl_cpu->set_speed_profile(p); });
+ return simix::simcall([this, p] { pimpl_cpu->set_speed_profile(p); });
}
/** @brief Get the peak processor speed (in flops/s), at the specified pstate */
double Host::get_pstate_speed(int pstate_index) const
{
- return simgrid::simix::simcall([this, pstate_index] { return this->pimpl_cpu->get_pstate_peak_speed(pstate_index); });
+ return simix::simcall([this, pstate_index] { return this->pimpl_cpu->get_pstate_peak_speed(pstate_index); });
}
/** @brief Get the peak computing speed in flops/s at the current pstate, NOT taking the external load into account.
/** @brief Set the pstate at which the host should run */
void Host::set_pstate(int pstate_index)
{
- simgrid::simix::simcall([this, pstate_index] { this->pimpl_cpu->set_pstate(pstate_index); });
+ simix::simcall([this, pstate_index] { this->pimpl_cpu->set_pstate(pstate_index); });
}
/** @brief Retrieve the pstate at which the host is currently running */
int Host::get_pstate() const
*/
std::vector<const char*> Host::get_attached_storages() const
{
- return simgrid::simix::simcall([this] { return this->pimpl_->get_attached_storages(); });
+ return simix::simcall([this] { return this->pimpl_->get_attached_storages(); });
}
void Host::getAttachedStorages(std::vector<const char*>* storages)
{
- std::vector<const char*> local_storages =
- simgrid::simix::simcall([this] { return this->pimpl_->get_attached_storages(); });
+ std::vector<const char*> local_storages = simix::simcall([this] { return this->pimpl_->get_attached_storages(); });
for (auto elm : local_storages)
storages->push_back(elm);
}
/** @brief Returns the amount of flops that remain to be done */
double Io::get_remaining()
{
- return simgrid::simix::simcall(
+ return simix::simcall(
[this]() { return boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)->get_remaining(); });
}
sg_size_t Io::get_performed_ioops()
{
- return simgrid::simix::simcall(
+ return simix::simcall(
[this]() { return boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)->get_performed_ioops(); });
}
namespace simgrid {
namespace s4u {
-simgrid::xbt::signal<void(Link&)> Link::on_creation;
-simgrid::xbt::signal<void(Link&)> Link::on_destruction;
-simgrid::xbt::signal<void(Link&)> Link::on_state_change;
-simgrid::xbt::signal<void(Link&)> Link::on_bandwidth_change;
-simgrid::xbt::signal<void(kernel::resource::NetworkAction*, Host* src, Host* dst)> Link::on_communicate;
-simgrid::xbt::signal<void(kernel::resource::NetworkAction*, kernel::resource::Action::State)>
+xbt::signal<void(Link&)> Link::on_creation;
+xbt::signal<void(Link&)> Link::on_destruction;
+xbt::signal<void(Link&)> Link::on_state_change;
+xbt::signal<void(Link&)> Link::on_bandwidth_change;
+xbt::signal<void(kernel::resource::NetworkAction*, Host* src, Host* dst)> Link::on_communicate;
+xbt::signal<void(kernel::resource::NetworkAction*, kernel::resource::Action::State)>
Link::on_communication_state_change;
Link* Link::by_name(const std::string& name)
namespace simgrid {
namespace s4u {
-const simgrid::xbt::string& Mailbox::get_name() const
+const xbt::string& Mailbox::get_name() const
{
return pimpl_->get_name();
}
namespace simgrid {
namespace s4u {
-simgrid::xbt::signal<void(bool symmetrical, kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
- kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
- std::vector<kernel::resource::LinkImpl*>& link_list)>
+xbt::signal<void(bool symmetrical, kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
+ kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
+ std::vector<kernel::resource::LinkImpl*>& link_list)>
NetZone::on_route_creation;
-simgrid::xbt::signal<void(NetZone&)> NetZone::on_creation;
-simgrid::xbt::signal<void(NetZone&)> NetZone::on_seal;
+xbt::signal<void(NetZone&)> NetZone::on_creation;
+xbt::signal<void(NetZone&)> NetZone::on_seal;
NetZone::NetZone(kernel::routing::NetZoneImpl* impl) : pimpl_(impl) {}
std::unordered_map<std::string, std::string>* NetZone::get_properties()
{
- return simgrid::simix::simcall([this] { return &properties_; });
+ return simix::simcall([this] { return &properties_; });
}
/** Retrieve the property value (or nullptr if not set) */
}
void NetZone::set_property(const std::string& key, const std::string& value)
{
- simgrid::simix::simcall([this, &key, &value] { properties_[key] = value; });
+ simix::simcall([this, &key, &value] { properties_[key] = value; });
}
/** @brief Returns the list of direct children (no grand-children) */
return pimpl_->get_all_hosts();
}
-void NetZone::getHosts(std::vector<s4u::Host*>* whereto)
+void NetZone::getHosts(std::vector<Host*>* whereto)
{
for (auto const& card : pimpl_->get_vertices()) {
- s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->get_name());
+ Host* host = Host::by_name_or_null(card->get_name());
if (host != nullptr)
whereto->push_back(host);
}
Semaphore::Semaphore(unsigned int initial_capacity)
{
- sem_ = simgrid::simix::simcall([initial_capacity] { return new kernel::activity::SemaphoreImpl(initial_capacity); });
+ sem_ = simix::simcall([initial_capacity] { return new kernel::activity::SemaphoreImpl(initial_capacity); });
}
Semaphore::~Semaphore()
void Semaphore::release()
{
- simgrid::simix::simcall([this] { sem_->release(); });
+ simix::simcall([this] { sem_->release(); });
}
int Semaphore::get_capacity()
{
- return simgrid::simix::simcall([this] { return sem_->get_capacity(); });
+ return simix::simcall([this] { return sem_->get_capacity(); });
}
int Semaphore::would_block()
{
- return simgrid::simix::simcall([this] { return sem_->would_block(); });
+ return simix::simcall([this] { return sem_->would_block(); });
}
void intrusive_ptr_add_ref(Semaphore* sem)
}
}
-}
-}
+} // namespace s4u
+} // namespace simgrid
+
/* **************************** Public C interface *************************** */
/** @brief creates a semaphore object of the given initial capacity */
sg_sem_t sg_sem_init(int initial_value)
namespace simgrid {
namespace xbt {
-template class Extendable<simgrid::s4u::Storage>;
+template class Extendable<s4u::Storage>;
} // namespace xbt
namespace s4u {
std::unordered_map<std::string, std::string>* Storage::get_properties()
{
- return simgrid::simix::simcall([this] { return pimpl_->get_properties(); });
+ return simix::simcall([this] { return pimpl_->get_properties(); });
}
const char* Storage::get_property(const std::string& key)
void Storage::set_property(const std::string& key, const std::string& value)
{
- simgrid::simix::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
+ simix::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
}
IoPtr Storage::io_init(sg_size_t size, Io::OpType type)