void CpuModel::updateActionsStateLazy(double now, double /*delta*/)
{
- while ((xbt_heap_size(getActionHeap()) > 0)
- && (double_equals(xbt_heap_maxkey(getActionHeap()), now, sg_surf_precision))) {
+ while (not actionHeapIsEmpty() && double_equals(actionHeapTopDate(), now, sg_surf_precision)) {
- CpuAction *action = static_cast<CpuAction*>(xbt_heap_pop(getActionHeap()));
+ CpuAction* action = static_cast<CpuAction*>(actionHeapPop());
XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
if (TRACE_is_enabled()) {
Cpu *cpu = static_cast<Cpu*>(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)));
}
/* get the min next event if heap not empty */
- if (xbt_heap_size(getActionHeap()) > 0)
- min_action_duration = xbt_heap_maxkey(getActionHeap()) - now;
+ if (not actionHeapIsEmpty())
+ min_action_duration = actionHeapTopDate() - now;
XBT_DEBUG("Share resources, min next event date: %f", min_action_duration);
void CpuTiModel::updateActionsState(double now, double /*delta*/)
{
- while ((xbt_heap_size(getActionHeap()) > 0) && (xbt_heap_maxkey(getActionHeap()) <= now)) {
- CpuTiAction* action = static_cast<CpuTiAction*>(xbt_heap_pop(getActionHeap()));
+ while (not actionHeapIsEmpty() && actionHeapTopDate() <= now) {
+ CpuTiAction* action = static_cast<CpuTiAction*>(actionHeapPop());
XBT_DEBUG("Action %p: finish", action);
action->finish(Action::State::done);
/* set the remains to 0 due to precision problems when updating the remaining amount */
void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/)
{
- while ((xbt_heap_size(getActionHeap()) > 0) &&
- (double_equals(xbt_heap_maxkey(getActionHeap()), now, sg_surf_precision))) {
+ while (not actionHeapIsEmpty() && double_equals(actionHeapTopDate(), now, sg_surf_precision)) {
- NetworkCm02Action* action = static_cast<NetworkCm02Action*>(xbt_heap_pop(getActionHeap()));
+ NetworkCm02Action* action = static_cast<NetworkCm02Action*>(actionHeapPop());
XBT_DEBUG("Something happened to action %p", action);
if (TRACE_is_enabled()) {
int n = lmm_get_number_of_cnst_from_var(maxminSystem_, action->getVariable());
}
//hereafter must have already the min value for this resource model
- if (xbt_heap_size(actionHeap_) > 0) {
- double min = xbt_heap_maxkey(actionHeap_) - now;
+ if (not actionHeapIsEmpty()) {
+ double min = actionHeapTopDate() - now;
XBT_DEBUG("minimum with the HEAP %f", min);
return min;
} else {
/** @brief Get Action heap */
xbt_heap_t getActionHeap() {return actionHeap_;}
+ double actionHeapTopDate() const { return xbt_heap_maxkey(actionHeap_); }
+ Action* actionHeapPop() { return static_cast<Action*>(xbt_heap_pop(actionHeap_)); }
+ bool actionHeapIsEmpty() const { return xbt_heap_size(actionHeap_) == 0; }
+
/**
* @brief Share the resources between the actions
*