X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/aaffb07de850abf8415c745e19fd8f1eec888a0f..f95d001733819381a8b927263af8925c6cb581c4:/src/surf/surf_interface.cpp diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index f9c967919a..df9b6b136b 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -365,7 +365,6 @@ Model::Model() doneActionSet_ = new ActionList(); modifiedSet_ = nullptr; - actionHeap_ = nullptr; updateMechanism_ = UM_UNDEFINED; selectiveUpdate_ = 0; } @@ -377,6 +376,14 @@ Model::~Model(){ delete doneActionSet_; } +Action* Model::actionHeapPop() +{ + Action* action = actionHeap_.top().second; + actionHeap_.pop(); + action->clearHeapHandle(); + return action; +} + double Model::nextOccuringEvent(double now) { //FIXME: set the good function once and for all @@ -442,8 +449,8 @@ double Model::nextOccuringEventLazy(double now) } //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 { @@ -456,7 +463,8 @@ double Model::nextOccuringEventFull(double /*now*/) { maxminSystem_->solve_fun(maxminSystem_); double min = -1; - for (auto it(getRunningActionSet()->begin()), itend(getRunningActionSet()->end()); it != itend ; ++it) { + + for (auto it(getRunningActionSet()->begin()); it != getRunningActionSet()->end(); ++it) { Action *action = &*it; double value = lmm_variable_getvalue(action->getVariable()); if (value > 0) { @@ -572,11 +580,6 @@ const char *surf_action_state_names[6] = { "SURF_ACTION_NOT_IN_THE_SYSTEM" }; -/* added to manage the communication action's heap */ -void surf_action_lmm_update_index_heap(void *action, int i) { - static_cast(action)->updateIndexHeap(i); -} - namespace simgrid { namespace surf { @@ -769,34 +772,31 @@ bool Action::isSuspended() * LATENCY = this is a heap entry to warn us when the latency is payed * MAX_DURATION =this is a heap entry to warn us when the max_duration limit is reached */ -void Action::heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat) +void Action::heapInsert(heap_type& heap, double key, enum heap_action_type hat) { hat_ = hat; - xbt_heap_push(heap, this, key); + heapHandle_ = heap.emplace(std::make_pair(key, this)); } -void Action::heapRemove(xbt_heap_t heap) +void Action::heapRemove(heap_type& heap) { hat_ = NOTSET; - if (indexHeap_ >= 0) { - xbt_heap_remove(heap, indexHeap_); + if (heapHandle_) { + heap.erase(*heapHandle_); + clearHeapHandle(); } } -void Action::heapUpdate(xbt_heap_t heap, double key, enum heap_action_type hat) +void Action::heapUpdate(heap_type& heap, double key, enum heap_action_type hat) { hat_ = hat; - if (indexHeap_ >= 0) { - xbt_heap_update(heap, indexHeap_, key); - }else{ - xbt_heap_push(heap, this, key); + if (heapHandle_) { + heap.update(*heapHandle_, std::make_pair(key, this)); + } else { + heapHandle_ = heap.emplace(std::make_pair(key, this)); } } -void Action::updateIndexHeap(int i) { - indexHeap_ = i; -} - double Action::getRemains() { XBT_IN("(%p)", this);