namespace activity {
ActivityImpl::~ActivityImpl()
+{
+ clean_action();
+ XBT_DEBUG("Destroy activity %p", this);
+}
+
+void ActivityImpl::clean_action()
{
if (surf_action_) {
surf_action_->unref();
- XBT_DEBUG("Destroy activity %p", this);
surf_action_ = nullptr;
}
}
virtual void post() = 0; // What to do when a simcall terminates
virtual void finish() = 0;
+ virtual void clean_action();
virtual double get_remaining() const;
// boost::intrusive_ptr<ActivityImpl> support:
friend XBT_PUBLIC void intrusive_ptr_add_ref(ActivityImpl* activity);
/** @brief This is part of the cleanup process, probably an internal command */
void CommImpl::cleanupSurf()
{
- if (surf_action_) {
- surf_action_->unref();
- surf_action_ = nullptr;
- }
+ clean_action();
if (src_timeout_) {
src_timeout_->unref();
CommImpl& set_type(CommImpl::Type type);
CommImpl& set_size(double size);
- double get_rate() { return rate_; }
- CommImpl& set_rate(double rate);
CommImpl& set_src_buff(void* buff, size_t size);
CommImpl& set_dst_buff(void* buff, size_t* size);
+ CommImpl& set_rate(double rate);
+ double get_rate() { return rate_; }
- CommImpl* start();
void copy_data();
+
+ CommImpl* start();
void suspend() override;
void resume() override;
+ void cancel() override;
void post() override;
void finish() override;
- void cancel() override;
CommImpl::Type type_; /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */
MailboxImpl* mbox = nullptr; /* Rendez-vous where the comm is queued */
on_completion(*this);
- if (surf_action_) {
- surf_action_->unref();
- surf_action_ = nullptr;
- }
+ clean_action();
+
if (timeout_detector_) {
timeout_detector_->unref();
timeout_detector_ = nullptr;
SIMIX_simcall_answer(simcall);
}
}
- SIMIX_process_sleep_destroy(this);
+
+ clean_action();
}
} // namespace activity
} // namespace kernel
if (exec != nullptr && exec->surf_action_) {
exec->cancel();
- exec->surf_action_->unref();
- exec->surf_action_ = nullptr;
+ exec->clean_action();
} else if (comm != nullptr) {
comms.remove(waiting_synchro);
comm->cancel();
activity::SleepImplPtr sleep = boost::dynamic_pointer_cast<activity::SleepImpl>(waiting_synchro);
if (sleep != nullptr) {
- SIMIX_process_sleep_destroy(sleep);
+ sleep->clean_action();
if (std::find(begin(simix_global->actors_to_run), end(simix_global->actors_to_run), this) ==
end(simix_global->actors_to_run) &&
this != SIMIX_process_self()) {
simgrid::kernel::activity::SleepImplPtr sleep =
boost::dynamic_pointer_cast<simgrid::kernel::activity::SleepImpl>(actor->waiting_synchro);
if (sleep != nullptr) {
- SIMIX_process_sleep_destroy(sleep);
+ sleep->clean_action();
if (std::find(begin(simix_global->actors_to_run), end(simix_global->actors_to_run), actor) ==
end(simix_global->actors_to_run) &&
actor != SIMIX_process_self()) {
simcall->issuer->waiting_synchro = sync;
}
-void SIMIX_process_sleep_destroy(simgrid::kernel::activity::SleepImplPtr sleep)
-{
- XBT_DEBUG("Destroy sleep synchro %p", sleep.get());
-
- if (sleep->surf_action_) {
- sleep->surf_action_->unref();
- sleep->surf_action_ = nullptr;
- }
-}
-
/**
* @brief Calling this function makes the process to yield.
*
extern void (*SMPI_switch_data_segment)(simgrid::s4u::ActorPtr actor);
-XBT_PRIVATE void SIMIX_process_sleep_destroy(simgrid::kernel::activity::SleepImplPtr synchro);
-
#endif