33#include <RobotComponents/interface/components/MotionPlanning/Tasks/RRTConnect/DataStructures.h>
49 (static_cast<
std::size_t>(
workerId) < u.dependetOnUpdateIds.size()))
50 ? u.dependetOnUpdateIds.at(
workerId) + 1
74 if (appliedUpdateIds.size() < count)
76 appliedUpdateIds.resize(count, -1);
83 setTrees(
const std::vector<std::reference_wrapper<Tree>>& newTrees)
96 return pendingUpdateLookupTable.find(
id) != pendingUpdateLookupTable.end();
108 return pendingUpdates.at(
id);
114 template <
class LockType,
class RemoteUpdateGetter>
121 template <
class LockType,
class RemoteUpdateGetter,
class UpdateConsumer>
124 RemoteUpdateGetter getRemoteUpdate,
125 UpdateConsumer updateConsumer)
131 for (; i < pendingUpdates.size(); ++i)
144 template <
class LockType,
class RemoteUpdateGetter,
class UpdateConsumer>
148 RemoteUpdateGetter getRemoteUpdate,
149 UpdateConsumer updateConsumer)
154 if (u.dependetOnUpdateIds.empty())
161 u.dependetOnUpdateIds.size());
174 prepareUpdate(u.dependetOnUpdateIds, lock, getRemoteUpdate, updateConsumer);
181 updateConsumer(std::move(u));
183 u.dependetOnUpdateIds.clear();
186 template <
class LockType,
class RemoteUpdateGetter,
class UpdateConsumer>
190 RemoteUpdateGetter getRemoteUpdate,
191 UpdateConsumer updateConsumer)
195 for (Ice::Long workerNodeId = 0;
196 static_cast<std::size_t
>(workerNodeId) < dependetOnUpdateIds.size();
199 const auto updateSubId = dependetOnUpdateIds.at(workerNodeId);
201 const UpdateId uId{workerNodeId, updateSubId};
222 Update update = getRemoteUpdate(workerNodeId, updateSubId);
226 update.dependetOnUpdateIds, lock, getRemoteUpdate, updateConsumer);
231 updateConsumer(std::move(update));
233 update.dependetOnUpdateIds.clear();
242 return (this->workerId == workerId) ||
243 ((
static_cast<std::size_t
>(workerId) < appliedUpdateIds.size())
244 ? updateSubId <= appliedUpdateIds.at(workerId)
256 const std::vector<Ice::Long>&
259 return appliedUpdateIds;
263 std::vector<std::reference_wrapper<Tree>> trees;
265 std::deque<Update> pendingUpdates;
266 std::map<UpdateId, std::size_t> pendingUpdateLookupTable;
268 std::vector<Ice::Long> appliedUpdateIds;
269 Ice::Long workerId = -1;
bool hasPendingUpdate(const UpdateId &id) const
void prepareUpdate(Ice::LongSeq dependetOnUpdateIds, LockType &&lock, RemoteUpdateGetter getRemoteUpdate, UpdateConsumer updateConsumer)
bool hasAppliedUpdate(const UpdateId &id) const
void applyUpdate(const Update &u)
void setWorkerCount(std::size_t count)
void applyPendingUpdates(LockType &&lock, RemoteUpdateGetter getRemoteUpdate, UpdateConsumer updateConsumer)
Update & getPendingUpdate(std::size_t id)
void setTrees(const std::vector< std::reference_wrapper< Tree > > &newTrees)
const std::vector< Ice::Long > & getAppliedUpdateIds() const
void applyPendingUpdate(Update &u, LockType &&lock, RemoteUpdateGetter getRemoteUpdate, UpdateConsumer updateConsumer)
void setWorkerId(Ice::Long newId)
void clearPendingUpdates()
void addPendingUpdate(const Update &u)
bool canApplyUpdate(const Update &u)
bool hasAppliedUpdate(Ice::Long workerId, Ice::Long updateSubId) const
Update & getPendingUpdate(const UpdateId &id)
void applyPendingUpdates(LockType &&lock, RemoteUpdateGetter getRemoteUpdate)
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
bool operator<(const UpdateId &other) const
UpdateId(const Update &u)
UpdateId(Ice::Long workerId=-1, Ice::Long updateSubId=-1)