32 return std::all_of(requestStrategies.begin(),
33 requestStrategies.end(),
34 [](ComputingPowerRequestStrategyBasePtr& s)
35 { return s->shouldAllocateComputingPower(); });
67 for (
auto& strat : strategyPerTaskStatus)
69 strat.second->updateNodeCount(count);
76 const auto it = strategyPerTaskStatus.find(newStatus);
77 current = (it == strategyPerTaskStatus.end()) ? nullptr : it->second.get();
79 for (
auto& strat : strategyPerTaskStatus)
81 strat.second->updateTaskStatus(newStatus);
88 for (
auto& strat : strategyPerTaskStatus)
90 strat.second->allocatedComputingPower();
99 for (
auto& strat : strategyPerTaskStatus)
101 strat.second->updateNodeCreations(nodesCreated, tries);
110 for (std::size_t i = 0; i < static_cast<std::size_t>(tries); ++i)
113 i < static_cast<std::size_t>(nodesCreated) ? 0 : 1;
123 const auto usedTimeDelta = timeDeltaInSeconds / (1.f + sigma * perc);
132 allocatedLastTime += std::chrono::seconds{
static_cast<std::size_t
>(usedTimeDelta)};
139 for (
auto& s : requestStrategies)
141 s->setCurrentStateAsInitialState();
148 for (
auto& s : requestStrategies)
150 s->updateNodeCount(count);
158 for (
auto& s : requestStrategies)
160 s->updateTaskStatus(newStatus);
167 for (
auto& s : requestStrategies)
169 s->allocatedComputingPower();
178 for (
auto& s : requestStrategies)
180 s->updateNodeCreations(nodesCreated, tries);
DateTime now() const
Current date/time of the clock.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if all compounded strategies return true.
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
void updateNodeCount(Ice::Long count, const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Sets the next time to allocate depending on the flag skipping.
TimePoint allocatedLastTime
The time point when more power should be allocated again.
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Updates the number of failed node creations.
std::size_t currentBacklogIndex
The current index in the backlog.
std::vector< char > backlog
The backlog.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
void updateNodeCount(Ice::Long count, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current &=Ice::emptyCurrent) override
Switches the current strategy and passes this call to all sub strategies.
ComputingPowerRequestStrategyBase * current
The current strategy in use.
Ice::Long nodeCount
The current node count.
Ice::Long allocateNextTime
The count when to allocate more power.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Sets the next creation count to allocate depending on the flag skipping.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
This file offers overloads of toIce() and fromIce() functions for STL container types.