namespace kernel {
namespace activity {
-ExecImpl::~ExecImpl()
-{
- if (timeout_detector_)
- timeout_detector_->unref();
- XBT_DEBUG("Destroy exec %p", this);
-}
-
ExecImpl& ExecImpl::set_host(s4u::Host* host)
{
if (not hosts_.empty())
ExecImpl& ExecImpl::set_timeout(double timeout)
{
if (timeout > 0 && not MC_is_active() && not MC_record_replay_is_active()) {
- timeout_detector_ = hosts_.front()->pimpl_cpu->sleep(timeout);
+ timeout_detector_.reset(hosts_.front()->pimpl_cpu->sleep(timeout));
timeout_detector_->set_activity(this);
}
return *this;
}
clean_action();
-
- if (timeout_detector_) {
- timeout_detector_->unref();
- timeout_detector_ = nullptr;
- }
-
+ timeout_detector_.reset();
/* Answer all simcalls associated with the synchro */
finish();
}
namespace activity {
class XBT_PUBLIC ExecImpl : public ActivityImpl_T<ExecImpl> {
- resource::Action* timeout_detector_ = nullptr;
+ std::unique_ptr<resource::Action, std::function<void(resource::Action*)>> timeout_detector_{
+ nullptr, [](resource::Action* a) { a->unref(); }};
double sharing_penalty_ = 1.0;
double bound_ = 0.0;
std::vector<s4u::Host*> hosts_;
std::vector<double> flops_amounts_;
std::vector<double> bytes_amounts_;
- ~ExecImpl();
public:
ExecImpl& set_timeout(double timeout);