/** Cancel that activity */
virtual Activity* cancel() = 0;
/** Retrieve the current state of the activity */
- Activity::State get_state() { return state_; }
+ Activity::State get_state() const { return state_; }
void set_state(Activity::State state) { state_ = state; }
/** Tests whether the given activity is terminated yet. This is a pure function. */
virtual bool test() = 0;
- virtual const char* get_cname() = 0;
- virtual const std::string& get_name() = 0;
+ virtual const char* get_cname() const = 0;
+ virtual const std::string& get_name() const = 0;
/** Get the remaining amount of work that this Activity entails. When it's 0, it's done. */
- virtual double get_remaining();
+ virtual double get_remaining() const;
/** Set the [remaining] amount of work that this Activity will entail
*
* It is forbidden to change the amount of work once the Activity is started */
name_ = name;
return static_cast<AnyActivity*>(this);
}
- const std::string& get_name() { return name_; }
- const char* get_cname() { return name_.c_str(); }
+ const std::string& get_name() const override { return name_; }
+ const char* get_cname() const override { return name_.c_str(); }
AnyActivity* set_tracing_category(const std::string& category)
{
tracing_category_ = category;
return static_cast<AnyActivity*>(this);
}
- const std::string& get_tracing_category() { return tracing_category_; }
+ const std::string& get_tracing_category() const { return tracing_category_; }
AnyActivity* set_user_data(void* data)
{
return static_cast<AnyActivity*>(this);
}
- void* get_user_data() { return user_data_; }
+ void* get_user_data() const { return user_data_; }
#ifndef DOXYGEN
/* The refcounting is done in the ancestor class, Activity, but we want each of the classes benefiting of the CRTP
* (Exec, Comm, etc) to have smart pointers too, so we define these methods here, that forward the ptr_release and
CommPtr set_tracing_category(const std::string& category);
/** Retrieve the mailbox on which this comm acts */
- Mailbox* get_mailbox();
+ Mailbox* get_mailbox() const;
/** Retrieve the size of the received data. Not to be mixed with @ref Activity::set_remaining() */
- size_t get_dst_data_size();
+ size_t get_dst_data_size() const;
- Actor* get_sender();
+ Actor* get_sender() const;
};
} // namespace s4u
} // namespace simgrid
Exec* start() override = 0;
/** @brief On sequential executions, returns the amount of flops that remain to be done; This cannot be used on
* parallel executions. */
- virtual double get_remaining_ratio() = 0;
+ virtual double get_remaining_ratio() const = 0;
virtual ExecPtr set_host(Host* host) = 0;
Exec* wait() override;
ExecPtr set_host(Host* host) override;
- double get_remaining() override;
- double get_remaining_ratio() override;
+ double get_remaining() const override;
+ double get_remaining_ratio() const override;
};
class XBT_PUBLIC ExecPar : public Exec {
friend XBT_PUBLIC ExecPtr this_actor::exec_init(const std::vector<s4u::Host*>& hosts,
const std::vector<double>& flops_amounts,
const std::vector<double>& bytes_amounts);
- double get_remaining() override;
- double get_remaining_ratio() override;
+ double get_remaining() const override;
+ double get_remaining_ratio() const override;
Exec* start() override;
};
Io* cancel() override;
bool test() override;
- double get_remaining() override;
+ double get_remaining() const override;
sg_size_t get_performed_ioops() const;
};
wait_for(time_limit - now);
}
-double Activity::get_remaining()
+double Activity::get_remaining() const
{
return remains_;
}
return this;
}
-size_t Comm::get_dst_data_size()
+size_t Comm::get_dst_data_size() const
{
xbt_assert(state_ == State::FINISHED, "You cannot use %s before your communication terminated", __FUNCTION__);
return dst_buff_size_;
return false;
}
-Mailbox* Comm::get_mailbox()
+Mailbox* Comm::get_mailbox() const
{
return mailbox_;
}
-Actor* Comm::get_sender()
+Actor* Comm::get_sender() const
{
return sender_ ? sender_->ciface() : nullptr;
}
return this;
}
-double ExecSeq::get_remaining()
+double ExecSeq::get_remaining() const
{
return kernel::actor::simcall(
[this]() { return boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->get_remaining(); });
*
* The returned value is between 0 (completely done) and 1 (nothing done yet).
*/
-double ExecSeq::get_remaining_ratio()
+double ExecSeq::get_remaining_ratio() const
{
return kernel::actor::simcall(
[this]() { return boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->get_seq_remaining_ratio(); });
return this;
}
-double ExecPar::get_remaining_ratio()
+double ExecPar::get_remaining_ratio() const
{
return kernel::actor::simcall(
[this]() { return boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->get_par_remaining_ratio(); });
}
-double ExecPar::get_remaining()
+double ExecPar::get_remaining() const
{
XBT_WARN("Calling get_remaining() on a parallel execution is not allowed. Call get_remaining_ratio() instead.");
return get_remaining_ratio();
}
/** @brief Returns the amount of flops that remain to be done */
-double Io::get_remaining()
+double Io::get_remaining() const
{
return kernel::actor::simcall(
[this]() { return boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)->get_remaining(); });