X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/01c23e1330e93416df34eb6c4ee55022b4cec64c..6d145186f32771e549c6171cf9434c2c1e2710f4:/src/s4u/s4u_Activity.cpp diff --git a/src/s4u/s4u_Activity.cpp b/src/s4u/s4u_Activity.cpp index f1a24ae50d..18d27cf4c4 100644 --- a/src/s4u/s4u_Activity.cpp +++ b/src/s4u/s4u_Activity.cpp @@ -42,9 +42,35 @@ bool Activity::test() return false; } +Activity* Activity::suspend() +{ + if (suspended_) + return this; // Already suspended + suspended_ = true; + + if (state_ == State::STARTED) + pimpl_->suspend(); + + return this; +} + +Activity* Activity::resume() +{ + if (not suspended_) + return this; // nothing to restore when it's not suspended + + if (state_ == State::STARTED) + pimpl_->resume(); + + return this; +} + double Activity::get_remaining() const { - return remains_; + if (state_ == State::INITED || state_ == State::STARTING) + return remains_; + else + return pimpl_->get_remaining(); } Activity* Activity::set_remaining(double remains)