#include <unordered_map>
-#include "xbt/dict.h"
-#include "xbt/fifo.h"
+#include "xbt/signal.hpp"
#include "simgrid/link.h"
***********/
namespace simgrid {
+namespace surf {
+class NetworkAction;
+class Action;
+};
namespace s4u {
/** @brief A Link represents the network facilities between [hosts](\ref simgrid::s4u::Host) */
class Link {
external load). Trace must contain percentages (value between 0 and 1). */
void setLatencyTrace(tmgr_trace_t trace); /*< setup the trace file with latency events (peak latency changes due to
external load). Trace must contain absolute values */
+
+ /* The signals */
+ /** @brief Callback signal fired when a new Link is created */
+ static simgrid::xbt::signal<void(surf::LinkImpl*)> onCreation;
+
+ /** @brief Callback signal fired when a Link is destroyed */
+ static simgrid::xbt::signal<void(surf::LinkImpl*)> onDestruction;
+
+ /** @brief Callback signal fired when the state of a Link changes (when it is turned on or off) */
+ static simgrid::xbt::signal<void(surf::LinkImpl*)> onStateChange;
+
+ /** @brief Callback signal fired when a communication starts */
+ static simgrid::xbt::signal<void(surf::NetworkAction*, s4u::Host* src, s4u::Host* dst)> onCommunicate;
+
+ /** @brief Callback signal fired when a communication changes it state (ready/done/cancel) */
+ static simgrid::xbt::signal<void(surf::NetworkAction*)> onCommunicationStateChange;
};
}
}
this->pimpl_->setLatencyTrace(trace);
});
}
+
+/*************
+ * Callbacks *
+ *************/
+simgrid::xbt::signal<void(surf::LinkImpl*)> Link::onCreation;
+simgrid::xbt::signal<void(surf::LinkImpl*)> Link::onDestruction;
+simgrid::xbt::signal<void(surf::LinkImpl*)> Link::onStateChange;
+simgrid::xbt::signal<void(surf::NetworkAction*, s4u::Host* src, s4u::Host* dst)> Link::onCommunicate;
+simgrid::xbt::signal<void(surf::NetworkAction*)> Link::onCommunicationStateChange;
}
}
//always need the call backs to ASes (we need only the root AS),
//to create the rootContainer and the rootType properly
if (!TRACE_needs_platform()) return;
- simgrid::surf::LinkImpl::onCreation.connect(instr_routing_parse_start_link);
+ simgrid::s4u::Link::onCreation.connect(instr_routing_parse_start_link);
simgrid::s4u::onPlatformCreated.connect(instr_routing_parse_end_platform);
}
delete back_route;
XBT_OUT();
- LinkImpl::onCommunicate(action, src, dst);
+ simgrid::s4u::Link::onCommunicate(action, src, dst);
return action;
}
if (policy == SURF_LINK_FATPIPE)
lmm_constraint_shared(constraint());
- LinkImpl::onCreation(this);
+ simgrid::s4u::Link::onCreation(this);
}
-
-
void NetworkCm02Link::apply_event(tmgr_trace_iterator_t triggered, double value)
{
{
NetworkConstantAction *action = new NetworkConstantAction(this, size, sg_latency_factor);
- LinkImpl::onCommunicate(action, src, dst);
+ simgrid::s4u::Link::onCommunicate(action, src, dst);
return action;
}
xbt_dict_set(((NetworkIBModel*)surf_network_model)->active_nodes, host.cname(), act, nullptr);
}
-static void IB_action_state_changed_callback(
- simgrid::surf::NetworkAction *action,
- simgrid::surf::Action::State statein, simgrid::surf::Action::State stateout)
+static void IB_action_state_changed_callback(simgrid::surf::NetworkAction* action)
{
using simgrid::surf::NetworkIBModel;
using simgrid::surf::IBNode;
- if(statein!=simgrid::surf::Action::State::running || stateout!=simgrid::surf::Action::State::done)
+ if (action->getState() != simgrid::surf::Action::State::done)
return;
std::pair<IBNode*,IBNode*> pair = ((NetworkIBModel*)surf_network_model)->active_comms[action];
XBT_DEBUG("IB callback - action %p finished", action);
/* } */
void surf_network_model_init_IB()
{
- using simgrid::surf::networkActionStateChangedCallbacks;
-
if (surf_network_model)
return;
surf_network_model = new simgrid::surf::NetworkIBModel();
all_existing_models->push_back(surf_network_model);
- networkActionStateChangedCallbacks.connect(IB_action_state_changed_callback);
- simgrid::surf::LinkImpl::onCommunicate.connect(IB_action_init_callback);
+ simgrid::s4u::Link::onCommunicationStateChange.connect(IB_action_state_changed_callback);
+ simgrid::s4u::Link::onCommunicate.connect(IB_action_init_callback);
simgrid::s4u::Host::onCreation.connect(IB_create_host_callback);
xbt_cfg_setdefault_double("network/weight-S", 8775);
(kv.second)->destroy();
delete links;
}
-
- /*************
- * Callbacks *
- *************/
-
- simgrid::xbt::signal<void(LinkImpl*)> LinkImpl::onCreation;
- simgrid::xbt::signal<void(LinkImpl*)> LinkImpl::onDestruction;
- simgrid::xbt::signal<void(LinkImpl*)> LinkImpl::onStateChange;
-
- simgrid::xbt::signal<void(NetworkAction*, Action::State, Action::State)> networkActionStateChangedCallbacks;
- simgrid::xbt::signal<void(NetworkAction*, s4u::Host* src, s4u::Host* dst)> LinkImpl::onCommunicate;
}
}
{
if (!currentlyDestroying_) {
currentlyDestroying_ = true;
- onDestruction(this);
+ s4u::Link::onDestruction(this);
delete this;
}
}
{
if (isOff()) {
Resource::turnOn();
- onStateChange(this);
+ s4u::Link::onStateChange(this);
}
}
void LinkImpl::turnOff()
{
if (isOn()) {
Resource::turnOff();
- onStateChange(this);
+ s4u::Link::onStateChange(this);
}
}
void LinkImpl::setStateTrace(tmgr_trace_t trace)
**********/
void NetworkAction::setState(Action::State state){
- Action::State old = getState();
Action::setState(state);
- networkActionStateChangedCallbacks(this, old, state);
+ s4u::Link::onCommunicationStateChange(this);
}
}
class NetworkAction;
- /** @brief Callback signal fired when the state of a NetworkAction changes
- * Signature: `void(NetworkAction *action, simgrid::surf::Action::State old, simgrid::surf::Action::State current)` */
- XBT_PUBLIC_DATA(simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::Action::State, simgrid::surf::Action::State)>) networkActionStateChangedCallbacks;
-
/*********
* Model *
*********/
public:
/** @brief Public interface */
s4u::Link piface_;
- /** @brief Callback signal fired when a new Link is created */
- static simgrid::xbt::signal<void(surf::LinkImpl*)> onCreation;
-
- /** @brief Callback signal fired when a Link is destroyed */
- static simgrid::xbt::signal<void(surf::LinkImpl*)> onDestruction;
-
- /** @brief Callback signal fired when the state of a Link changes (when it is turned on or off) */
- static simgrid::xbt::signal<void(surf::LinkImpl*)> onStateChange;
-
- /** @brief Callback signal fired when a communication starts */
- static simgrid::xbt::signal<void(surf::NetworkAction*, s4u::Host* src, s4u::Host* dst)> onCommunicate;
/** @brief Get the bandwidth in bytes per second of current Link */
virtual double bandwidth();
if (policy == SURF_LINK_FATPIPE)
lmm_constraint_shared(constraint());
- LinkImpl::onCreation(this);
+ s4u::Link::onCreation(this);
}
Action *CpuL07::execution_start(double size)