s4u::Comm still uses old-style simcalls (thanks MC) and cannot use it now.
/** Retrieve the current state of the activity */
Activity::State get_state() const { return state_; }
void set_state(Activity::State state) { state_ = state; }
- /** Tests whether the given activity is terminated yet. This is a pure function. */
- virtual bool test() = 0;
+ /** Tests whether the given activity is terminated yet. */
+ virtual bool test();
+
virtual const char* get_cname() const = 0;
virtual const std::string& get_name() const = 0;
/*! Same as wait_any, but with a timeout. If the timeout occurs, parameter last is returned.*/
static int wait_any_for(std::vector<ExecPtr>* execs, double timeout);
- bool test() override;
-
ExecPtr set_bound(double bound);
ExecPtr set_priority(double priority);
XBT_ATTRIB_DEPRECATED_v329("Please use exec_init(...)->wait_for(timeout)") ExecPtr set_timeout(double timeout);
Io* wait() override;
Io* wait_for(double timeout) override;
Io* cancel() override;
- bool test() override;
double get_remaining() const override;
sg_size_t get_performed_ioops() const;
#include "simgrid/s4u/Activity.hpp"
#include "simgrid/s4u/Engine.hpp"
+#include "src/kernel/activity/ActivityImpl.hpp"
XBT_LOG_EXTERNAL_CATEGORY(s4u);
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_activity, s4u, "S4U activities");
wait_for(time_limit - now);
}
+bool Activity::test()
+{
+ xbt_assert(state_ == State::INITED || state_ == State::STARTED || state_ == State::STARTING ||
+ state_ == State::FINISHED);
+
+ if (state_ == State::FINISHED)
+ return true;
+
+ if (state_ == State::INITED || state_ == State::STARTING)
+ this->vetoable_start();
+
+ if (kernel::actor::simcall([this] { return this->get_impl()->test(); })) {
+ state_ = State::FINISHED;
+ this->release_dependencies();
+ return true;
+ }
+
+ return false;
+}
+
double Activity::get_remaining() const
{
return remains_;
pimpl_ = kernel::activity::ExecImplPtr(new kernel::activity::ExecImpl());
}
-bool Exec::test()
-{
- xbt_assert(state_ == State::INITED || state_ == State::STARTED || state_ == State::STARTING ||
- state_ == State::FINISHED);
-
- if (state_ == State::FINISHED)
- return true;
-
- if (state_ == State::INITED || state_ == State::STARTING)
- this->vetoable_start();
-
- if (kernel::actor::simcall([this] { return this->get_impl()->test(); })) {
- state_ = State::FINISHED;
- this->release_dependencies();
- return true;
- }
-
- return false;
-}
-
Exec* Exec::wait()
{
return this->wait_for(-1);
return this;
}
-bool Io::test()
-{
- xbt_assert(state_ == State::INITED || state_ == State::STARTED || state_ == State::STARTING ||
- state_ == State::FINISHED);
-
- if (state_ == State::FINISHED)
- return true;
-
- if (state_ == State::INITED || state_ == State::STARTING)
- this->vetoable_start();
-
- if (kernel::actor::simcall([this] { return this->get_impl()->test(); })) {
- state_ = State::FINISHED;
- this->release_dependencies();
- return true;
- }
-
- return false;
-}
-
/** @brief Returns the amount of flops that remain to be done */
double Io::get_remaining() const
{