/** @brief Unref that action (and destroy it if refcount reaches 0)
* @return true if the action was destroyed and false if someone still has references on it
*/
- virtual int unref();
+ int unref();
/** @brief Cancel the current Action if running */
virtual void cancel();
protected:
StateSet* state_set_;
- int refcount_ = 1;
private:
+ int refcount_ = 1;
double sharing_priority_ = 1.0; /**< priority (1.0 by default) */
double max_duration_ = NO_MAX_DURATION; /*< max_duration (may fluctuate until the task is completed) */
double remains_; /**< How much of that cost remains to be done in the currently running task */
Action::~Action()
{
+ if (state_set_hook_.is_linked())
+ simgrid::xbt::intrusive_erase(*state_set_, *this);
+ if (getVariable())
+ get_model()->getMaxminSystem()->variable_free(getVariable());
+ if (get_model()->getUpdateMechanism() == UM_LAZY) {
+ /* remove from heap */
+ heapRemove(get_model()->getActionHeap());
+ if (modified_set_hook_.is_linked())
+ simgrid::xbt::intrusive_erase(*get_model()->getModifiedSet(), *this);
+ }
+
xbt_free(category_);
}
{
refcount_--;
if (not refcount_) {
- if (state_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(*state_set_, *this);
- if (getVariable())
- get_model()->getMaxminSystem()->variable_free(getVariable());
- if (get_model()->getUpdateMechanism() == UM_LAZY) {
- /* remove from heap */
- heapRemove(get_model()->getActionHeap());
- if (modified_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(*get_model()->getModifiedSet(), *this);
- }
delete this;
return 1;
}
{
cpu_->modified(true);
}
-
-void CpuTiAction::set_state(Action::State state)
+CpuTiAction::~CpuTiAction()
{
- CpuAction::set_state(state);
+ /* remove from action_set */
+ if (action_ti_hook.is_linked())
+ simgrid::xbt::intrusive_erase(cpu_->actionSet_, *this);
+ /* remove from heap */
+ heapRemove(get_model()->getActionHeap());
cpu_->modified(true);
}
-int CpuTiAction::unref()
+void CpuTiAction::set_state(Action::State state)
{
- refcount_--;
- if (not refcount_) {
- if (state_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(*get_state_set(), *this);
- /* remove from action_set */
- if (action_ti_hook.is_linked())
- simgrid::xbt::intrusive_erase(cpu_->actionSet_, *this);
- /* remove from heap */
- heapRemove(get_model()->getActionHeap());
- cpu_->modified(true);
- delete this;
- return 1;
- }
- return 0;
+ CpuAction::set_state(state);
+ cpu_->modified(true);
}
void CpuTiAction::cancel()
friend class CpuTi;
public:
CpuTiAction(CpuTiModel *model, double cost, bool failed, CpuTi *cpu);
+ ~CpuTiAction();
void set_state(simgrid::kernel::resource::Action::State state) override;
- int unref() override;
void cancel() override;
void suspend() override;
void resume() override;
return false;
}
-int NetworkNS3Action::unref()
-{
- refcount_--;
- if (not refcount_) {
- if (state_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(*state_set_, *this);
- XBT_DEBUG ("Removing action %p", this);
- delete this;
- return 1;
- }
- return 0;
-}
-
}
}
NetworkNS3Action(kernel::resource::Model* model, double cost, s4u::Host* src, s4u::Host* dst);
bool isSuspended() override;
- int unref() override;
void suspend() override;
void resume() override;
std::list<LinkImpl*> links() override;
}
}
-int L07Action::unref()
-{
- refcount_--;
- if (not refcount_) {
- if (state_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(*state_set_, *this);
- if (getVariable())
- get_model()->getMaxminSystem()->variable_free(getVariable());
- delete this;
- return 1;
- }
- return 0;
-}
-
}
}
void updateBound();
- int unref() override;
-
std::vector<s4u::Host*>* hostList_ = new std::vector<s4u::Host*>();
double *computationAmount_;
double *communicationAmount_;
XBT_OUT();
}
-int StorageN11Action::unref()
-{
- refcount_--;
- if (not refcount_) {
- if (state_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(*state_set_, *this);
- if (getVariable())
- get_model()->getMaxminSystem()->variable_free(getVariable());
- xbt_free(get_category());
- delete this;
- return 1;
- }
- return 0;
-}
-
void StorageN11Action::cancel()
{
set_state(Action::State::failed);
StorageN11Action(kernel::resource::Model* model, double cost, bool failed, StorageImpl* storage,
e_surf_action_storage_type_t type);
void suspend() override;
- int unref() override;
void cancel() override;
void resume() override;
bool isSuspended() override;