* It is forbidden to change the amount of work once the Activity is started */
Activity* set_remaining(double remains);
- virtual void fire_on_completion() const = 0;
+ virtual void fire_on_start() const = 0;
+ virtual void fire_on_this_start() const = 0;
+ virtual void fire_on_completion() const = 0;
virtual void fire_on_this_completion() const = 0;
- virtual void fire_on_suspend() const = 0;
- virtual void fire_on_this_suspend() const = 0;
- virtual void fire_on_resume() const = 0;
- virtual void fire_on_this_resume() const = 0;
- virtual void fire_on_veto() const = 0;
- virtual void fire_on_this_veto() const = 0;
+ virtual void fire_on_suspend() const = 0;
+ virtual void fire_on_this_suspend() const = 0;
+ virtual void fire_on_resume() const = 0;
+ virtual void fire_on_this_resume() const = 0;
+ virtual void fire_on_veto() = 0;
+ virtual void fire_on_this_veto() = 0;
public:
void start()
std::string name_ = "unnamed";
std::string tracing_category_ = "";
-protected:
+ inline static xbt::signal<void(AnyActivity const&)> on_start;
+ xbt::signal<void(AnyActivity const&)> on_this_start;
inline static xbt::signal<void(AnyActivity const&)> on_completion;
xbt::signal<void(AnyActivity const&)> on_this_completion;
inline static xbt::signal<void(AnyActivity const&)> on_suspend;
inline static xbt::signal<void(AnyActivity&)> on_veto;
xbt::signal<void(AnyActivity&)> on_this_veto;
+protected:
+ void fire_on_start() const override { on_start(static_cast<const AnyActivity&>(*this)); }
+ void fire_on_this_start() const override { on_this_start(static_cast<const AnyActivity&>(*this)); }
+ void fire_on_completion() const override { on_completion(static_cast<const AnyActivity&>(*this)); }
+ void fire_on_this_completion() const override { on_this_completion(static_cast<const AnyActivity&>(*this)); }
+ void fire_on_suspend() const override { on_suspend(static_cast<const AnyActivity&>(*this)); }
+ void fire_on_this_suspend() const override { on_this_suspend(static_cast<const AnyActivity&>(*this)); }
+ void fire_on_resume() const override { on_resume(static_cast<const AnyActivity&>(*this)); }
+ void fire_on_this_resume() const override { on_this_resume(static_cast<const AnyActivity&>(*this)); }
+ void fire_on_veto() override { on_veto(static_cast<AnyActivity&>(*this)); }
+ void fire_on_this_veto() override { on_this_veto(static_cast<AnyActivity&>(*this)); }
+
public:
+ /*! \static Add a callback fired when any activity starts (no veto) */
+ static void on_start_cb(const std::function<void(AnyActivity const&)>& cb) { on_start.connect(cb); }
+ /*! Add a callback fired when this specific activity starts (no veto) */
+ void on_this_start_cb(const std::function<void(AnyActivity const&)>& cb) { on_this_start.connect(cb); }
/*! \static Add a callback fired when any activity completes (either normally, cancelled or failed) */
static void on_completion_cb(const std::function<void(AnyActivity const&)>& cb) { on_completion.connect(cb); }
/*! Add a callback fired when this specific activity completes (either normally, cancelled or failed) */
xbt::signal<void(Comm const&)> on_this_send;
static xbt::signal<void(Comm const&)> on_recv;
xbt::signal<void(Comm const&)> on_this_recv;
- inline static xbt::signal<void(Comm const&)> on_start;
- xbt::signal<void(Comm const&)> on_this_start;
protected:
void fire_on_completion() const override {
}
void fire_on_this_completion() const override {
/* The completion signal of a Comm has to be thrown only once and not by the sender AND the receiver.
- then Comm::on_completion is thrown in the kernel in CommImpl::finish.
+ then Comm::on_this_completion is thrown in the kernel in CommImpl::finish.
*/
}
- void fire_on_suspend() const override { on_suspend(*this); }
- void fire_on_this_suspend() const override { on_this_suspend(*this); }
- void fire_on_resume() const override { on_resume(*this); }
- void fire_on_this_resume() const override { on_this_resume(*this); }
- void fire_on_veto() const override { on_veto(const_cast<Comm&>(*this)); }
- void fire_on_this_veto() const override { on_this_veto(const_cast<Comm&>(*this)); }
+ /* These ensure that the on_completion signals are really thrown */
+ void fire_on_completion_for_real() const { Activity_T<Comm>::fire_on_completion(); }
+ void fire_on_this_completion_for_real() const { Activity_T<Comm>::fire_on_this_completion(); }
public:
/*! \static Add a callback fired when the send of any Comm is posted */
static void on_recv_cb(const std::function<void(Comm const&)>& cb) { on_recv.connect(cb); }
/*! Add a callback fired when the recv of this specific Comm is posted */
void on_this_recv_cb(const std::function<void(Comm const&)>& cb) { on_this_recv.connect(cb); }
- /*! \static Add a callback fired when any Comm starts */
- static void on_start_cb(const std::function<void(Comm const&)>& cb) { on_start.connect(cb); }
- /*! Add a callback fired when this specific Comm starts */
- void on_this_start_cb(const std::function<void(Comm const&)>& cb) { on_this_start.connect(cb); }
CommPtr set_copy_data_callback(const std::function<void(kernel::activity::CommImpl*, void*, size_t)>& callback);
XBT_ATTRIB_DEPRECATED_v338("Please manifest if you actually need this function") static void copy_buffer_callback(
bool parallel_ = false;
- inline static xbt::signal<void(Exec const&)> on_start;
- xbt::signal<void(Exec const&)> on_this_start;
-
protected:
explicit Exec(kernel::activity::ExecImplPtr pimpl);
Exec* do_start() override;
void reset() const;
- void fire_on_completion() const override { on_completion(*this); }
- void fire_on_this_completion() const override { on_this_completion(*this); }
- void fire_on_suspend() const override { on_suspend(*this); }
- void fire_on_this_suspend() const override { on_this_suspend(*this); }
- void fire_on_resume() const override { on_resume(*this); }
- void fire_on_this_resume() const override { on_this_resume(*this); }
- void fire_on_veto() const override { on_veto(const_cast<Exec&>(*this)); }
- void fire_on_this_veto() const override { on_this_veto(const_cast<Exec&>(*this)); }
-
public:
#ifndef DOXYGEN
Exec(Exec const&) = delete;
Exec& operator=(Exec const&) = delete;
#endif
- /*! \static Signal fired each time that any execution actually starts (no veto) */
- static void on_start_cb(const std::function<void(Exec const&)>& cb) { on_start.connect(cb); }
- /*! Signal fired each time that this specific execution actually starts (no veto) */
- void on_this_start_cb(const std::function<void(Exec const&)>& cb) { on_this_start.connect(cb); }
-
/*! \static Initiate the creation of an Exec. Setters have to be called afterwards */
static ExecPtr init();
friend kernel::EngineImpl;
#endif
- inline static xbt::signal<void(Io const&)> on_start;
- xbt::signal<void(Io const&)> on_this_start;
-
protected:
explicit Io(kernel::activity::IoImplPtr pimpl);
Io* do_start() override;
- void fire_on_completion() const override { on_completion(*this); }
- void fire_on_this_completion() const override { on_this_completion(*this); }
- void fire_on_suspend() const override { on_suspend(*this); }
- void fire_on_this_suspend() const override { on_this_suspend(*this); }
- void fire_on_resume() const override { on_resume(*this); }
- void fire_on_this_resume() const override { on_this_resume(*this); }
- void fire_on_veto() const override { on_veto(const_cast<Io&>(*this)); }
- void fire_on_this_veto() const override { on_this_veto(const_cast<Io&>(*this)); }
public:
enum class OpType { READ, WRITE };
- /*! \static Signal fired each time that any I/O actually starts (no veto) */
- static void on_start_cb(const std::function<void(Io const&)>& cb) { on_start.connect(cb); }
- /*! Signal fired each time this specific I/O actually starts (no veto) */
- void on_this_start_cb(const std::function<void(Io const&)>& cb) { on_this_start.connect(cb); }
-
/*! \static Initiate the creation of an I/O. Setters have to be called afterwards */
static IoPtr init();
/*! \static take a vector of s4u::IoPtr and return when one of them is finished.
if (get_iface()) {
const auto& piface = static_cast<const s4u::Comm&>(*get_iface());
set_iface(nullptr); // reset iface to protect against multiple trigger of the on_completion signals
- s4u::Comm::on_completion(piface);
- piface.on_this_completion(piface);
+ piface.fire_on_completion_for_real();
+ piface.fire_on_this_completion_for_real();
}
/* Update synchro state */
xbt_assert(src_buff_ == nullptr && dst_buff_ == nullptr,
"Direct host-to-host communications cannot carry any data.");
XBT_DEBUG("host-to-host Comm. Pimpl already created and set, just start it.");
- on_start(*this);
- on_this_start(*this);
+ fire_on_start();
+ fire_on_this_start();
kernel::actor::simcall_answered([this] {
pimpl_->set_state(kernel::activity::State::READY);
boost::static_pointer_cast<kernel::activity::CommImpl>(pimpl_)->start();
pimpl_->set_actor(sender_);
// Only throw the signal when both sides are here and the status is READY
if (pimpl_->get_state() != kernel::activity::State::WAITING) {
- on_start(*this);
- on_this_start(*this);
+ fire_on_start();
+ fire_on_this_start();
}
}
pimpl_->suspend();
state_ = State::STARTED;
- on_start(*this);
- on_this_start(*this);
+ fire_on_start();
+ fire_on_this_start();
return this;
}
pimpl_->suspend();
state_ = State::STARTED;
- on_start(*this);
- on_this_start(*this);
+ fire_on_start();
+ fire_on_this_start();
return this;
}