X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/396200308fb93b455f0e0fe14a8b64410e51671c..343da621d4fc46b8d15c839a5e21bb45fce68e27:/src/s4u/s4u_Exec.cpp diff --git a/src/s4u/s4u_Exec.cpp b/src/s4u/s4u_Exec.cpp index cd5c6d54da..a0d3cc5302 100644 --- a/src/s4u/s4u_Exec.cpp +++ b/src/s4u/s4u_Exec.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -22,16 +22,18 @@ Exec::Exec() bool Exec::test() { - xbt_assert(state_ == State::INITED || state_ == State::STARTED || state_ == State::FINISHED); + xbt_assert(state_ == State::INITED || state_ == State::STARTED || state_ == State::STARTING || + state_ == State::FINISHED); if (state_ == State::FINISHED) return true; - if (state_ == State::INITED) - this->start(); + if (state_ == State::INITED || state_ == State::STARTING) + this->vetoable_start(); if (simcall_execution_test(pimpl_)) { state_ = State::FINISHED; + this->release_dependencies(); return true; } @@ -46,10 +48,11 @@ Exec* Exec::wait() Exec* Exec::wait_for(double timeout) { if (state_ == State::INITED) - start(); + vetoable_start(); simcall_execution_wait(pimpl_, timeout); state_ = State::FINISHED; on_completion(*Actor::self(), *this); + this->release_dependencies(); return this; } @@ -58,7 +61,11 @@ int Exec::wait_any_for(std::vector* execs, double timeout) std::unique_ptr rexecs(new kernel::activity::ExecImpl*[execs->size()]); std::transform(begin(*execs), end(*execs), rexecs.get(), [](const ExecPtr& exec) { return static_cast(exec->pimpl_.get()); }); - return simcall_execution_waitany_for(rexecs.get(), execs->size(), timeout); + + int changed_pos = simcall_execution_waitany_for(rexecs.get(), execs->size(), timeout); + if (changed_pos != -1) + execs->at(changed_pos)->release_dependencies(); + return changed_pos; } Exec* Exec::cancel()