Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
allow to cancel a s4u::Exec
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Sat, 28 Jul 2018 22:23:50 +0000 (00:23 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Sat, 28 Jul 2018 22:23:50 +0000 (00:23 +0200)
include/simgrid/s4u/Activity.hpp
include/simgrid/s4u/Comm.hpp
include/simgrid/s4u/Exec.hpp
src/s4u/s4u_Exec.cpp

index 4db481e..7e53d03 100644 (file)
@@ -57,7 +57,7 @@ public:
    *  Raises: timeout exception.*/
   virtual Activity* wait(double timeout) = 0;
   /** Cancel that activity */
    *  Raises: timeout exception.*/
   virtual Activity* wait(double timeout) = 0;
   /** Cancel that activity */
-  //virtual void cancel();
+  virtual Activity* cancel() = 0;
   /** Retrieve the current state of the activity */
   Activity::State get_state() { return state_; }
 
   /** Retrieve the current state of the activity */
   Activity::State get_state() { return state_; }
 
index 0140476..dd24d51 100644 (file)
@@ -69,7 +69,7 @@ public:
   size_t get_dst_data_size();
 
   bool test();
   size_t get_dst_data_size();
 
   bool test();
-  Activity* cancel();
+  Activity* cancel() override;
 
   /** Retrieve the mailbox on which this comm acts */
   MailboxPtr get_mailbox();
 
   /** Retrieve the mailbox on which this comm acts */
   MailboxPtr get_mailbox();
index 9616bfe..b47ac41 100644 (file)
@@ -26,6 +26,7 @@ public:
   Activity* start() override;
   Activity* wait() override;
   Activity* wait(double timeout) override;
   Activity* start() override;
   Activity* wait() override;
   Activity* wait(double timeout) override;
+  Activity* cancel() override;
   bool test();
 
   ExecPtr set_priority(double priority);
   bool test();
 
   ExecPtr set_priority(double priority);
index dc9c7a9..94da9d2 100644 (file)
@@ -20,6 +20,13 @@ Activity* Exec::start()
   return this;
 }
 
   return this;
 }
 
+Activity* Exec::cancel()
+{
+  simcall_execution_cancel(pimpl_);
+  state_ = State::CANCELED;
+  return this;
+}
+
 Activity* Exec::wait()
 {
   simcall_execution_wait(pimpl_);
 Activity* Exec::wait()
 {
   simcall_execution_wait(pimpl_);