A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #237 from oar-team/upstream
[simgrid.git]
/
src
/
surf
/
surf_interface.cpp
diff --git
a/src/surf/surf_interface.cpp
b/src/surf/surf_interface.cpp
index
01318ca
..
999fca9
100644
(file)
--- a/
src/surf/surf_interface.cpp
+++ b/
src/surf/surf_interface.cpp
@@
-365,20
+365,25
@@
Model::Model()
doneActionSet_ = new ActionList();
modifiedSet_ = nullptr;
doneActionSet_ = new ActionList();
modifiedSet_ = nullptr;
- actionHeap_ = xbt_heap_new(8, nullptr);
- xbt_heap_set_update_callback(actionHeap_, surf_action_lmm_update_index_heap);
updateMechanism_ = UM_UNDEFINED;
selectiveUpdate_ = 0;
}
Model::~Model(){
updateMechanism_ = UM_UNDEFINED;
selectiveUpdate_ = 0;
}
Model::~Model(){
- xbt_heap_free(actionHeap_);
delete readyActionSet_;
delete runningActionSet_;
delete failedActionSet_;
delete doneActionSet_;
}
delete readyActionSet_;
delete runningActionSet_;
delete failedActionSet_;
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
double Model::nextOccuringEvent(double now)
{
//FIXME: set the good function once and for all
@@
-458,7
+463,8
@@
double Model::nextOccuringEventFull(double /*now*/) {
maxminSystem_->solve_fun(maxminSystem_);
double min = -1;
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) {
Action *action = &*it;
double value = lmm_variable_getvalue(action->getVariable());
if (value > 0) {
@@
-574,11
+580,6
@@
const char *surf_action_state_names[6] = {
"SURF_ACTION_NOT_IN_THE_SYSTEM"
};
"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<simgrid::surf::Action*>(action)->updateIndexHeap(i);
-}
-
namespace simgrid {
namespace surf {
namespace simgrid {
namespace surf {
@@
-607,7
+608,7
@@
void Action::finish(Action::State state)
setState(state);
}
setState(state);
}
-Action::State Action::getState()
+Action::State Action::getState()
const
{
if (stateSet_ == model_->getReadyActionSet())
return Action::State::ready;
{
if (stateSet_ == model_->getReadyActionSet())
return Action::State::ready;
@@
-644,7
+645,7
@@
void Action::setState(Action::State state)
stateSet_->push_back(*this);
}
stateSet_->push_back(*this);
}
-double Action::getBound()
+double Action::getBound()
const
{
return (variable_) ? lmm_variable_getbound(variable_) : 0;
}
{
return (variable_) ? lmm_variable_getbound(variable_) : 0;
}
@@
-660,21
+661,6
@@
void Action::setBound(double bound)
XBT_OUT();
}
XBT_OUT();
}
-double Action::getStartTime()
-{
- return start_;
-}
-
-double Action::getFinishTime()
-{
- return finishTime_;
-}
-
-void Action::setData(void* data)
-{
- data_ = data;
-}
-
void Action::setCategory(const char *category)
{
category_ = xbt_strdup(category);
void Action::setCategory(const char *category)
{
category_ = xbt_strdup(category);
@@
-771,34
+757,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
*/
* 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;
{
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;
{
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;
{
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);
double Action::getRemains()
{
XBT_IN("(%p)", this);
@@
-809,10
+792,5
@@
double Action::getRemains()
return remains_;
}
return remains_;
}
-double Action::getRemainsNoUpdate()
-{
- return remains_;
-}
-
}
}
}
}