- StorageAction *action = NULL;
-
- ActionList *actionSet = getRunningActionSet();
- for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end())
- ; it != itend ; it=itNext) {
- ++itNext;
- action = static_cast<StorageAction*>(&*it);
-
- if(action->m_type == WRITE)
- {
- // Update the disk usage
- // Update the file size
- // For each action of type write
- volatile double current_progress =
- delta * lmm_variable_getvalue(action->getVariable());
- long int incr = current_progress;
-
- XBT_DEBUG("%s:\n\t progress = %.2f, current_progress = %.2f, "
- "incr = %ld, lrint(1) = %ld, lrint(2) = %ld",
- action->p_file->name,
- action->progress, current_progress, incr,
- lrint(action->progress + current_progress),
- lrint(action->progress)+ incr);
-
- /* take care of rounding error accumulation */
- if (lrint(action->progress + current_progress) >
- lrint(action->progress)+ incr)
- incr++;
-
- action->progress +=current_progress;
-
- action->p_storage->m_usedSize += incr; // disk usage
- action->p_file->current_position+= incr; // current_position
- // which becomes the new file size
- action->p_file->size = action->p_file->current_position ;
-
- sg_size_t *psize = xbt_new(sg_size_t,1);
- *psize = action->p_file->size;
- xbt_dict_t content_dict = action->p_storage->p_content;
- xbt_dict_set(content_dict, action->p_file->name, psize, NULL);
- }
+ for (auto it = std::begin(*getRunningActionSet()); it != std::end(*getRunningActionSet());) {
+ StorageAction& action = static_cast<StorageAction&>(*it);
+ ++it; // increment iterator here since the following calls to action.finish() may invalidate it
+ action.updateRemains(lrint(action.getVariable()->get_value() * delta));
+
+ if (action.getMaxDuration() > NO_MAX_DURATION)
+ action.updateMaxDuration(delta);