Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into depencencies
[simgrid.git] / src / s4u / s4u_Io.cpp
index a95426b..73149eb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-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. */
@@ -61,23 +61,28 @@ Io* Io::wait()
 
 Io* Io::wait_for(double timeout)
 {
+  if (state_ == State::INITED)
+    vetoable_start();
   simcall_io_wait(pimpl_, timeout);
   state_ = State::FINISHED;
+  this->release_dependencies();
   return this;
 }
 
 bool Io::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_io_test(pimpl_)) {
     state_ = State::FINISHED;
+    this->release_dependencies();
     return true;
   }