+Exec* Exec::wait()
+{
+ if (state_ == State::INITED)
+ start();
+ simcall_execution_wait(pimpl_);
+ state_ = State::FINISHED;
+ on_completion(*Actor::self());
+ return this;
+}
+
+Exec* Exec::wait_for(double)
+{
+ THROW_UNIMPLEMENTED;
+}
+
+Exec* Exec::cancel()
+{
+ simix::simcall([this] { boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->cancel(); });
+ state_ = State::CANCELED;
+ return this;
+}
+
+void intrusive_ptr_release(simgrid::s4u::Exec* e)
+{
+ if (e->refcount_.fetch_sub(1, std::memory_order_release) == 1) {
+ std::atomic_thread_fence(std::memory_order_acquire);
+ delete e;
+ }
+}
+
+void intrusive_ptr_add_ref(simgrid::s4u::Exec* e)
+{
+ e->refcount_.fetch_add(1, std::memory_order_relaxed);
+}
+
+/** @brief change the execution bound
+ * This means changing the maximal amount of flops per second that it may consume, regardless of what the host may
+ * deliver. Currently, this cannot be changed once the exec started.
+ */
+ExecPtr Exec::set_bound(double bound)
+{
+ xbt_assert(state_ == State::INITED, "Cannot change the bound of an exec after its start");
+ bound_ = bound;
+ return this;
+}
+ExecPtr Exec::set_timeout(double timeout)
+{
+ xbt_assert(state_ == State::INITED, "Cannot change the bound of an exec after its start");
+ timeout_ = timeout;
+ return this;
+}
+
+ExecPtr Exec::set_name(const std::string& name)
+{
+ xbt_assert(state_ == State::INITED, "Cannot change the name of an exec after its start");
+ name_ = name;
+ return this;
+}
+