Introduce a sorted set for workcell tasks #124
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #102
A simple implementation of an ordered data structure for tasks stored at the workcell orchestrator level (in the end a
setrather than apriority_queueas proposed, I think priority queues don't allow reordering items at runtime).Changing from a fixed FIFO to a random access (but still ordered) data structure, allows the system orchestrator to request task execution for previously queued tasks at any time, without being forced to use the same order tasks were enqueued. This should allow higher efficiency as well as preventing deadlocks when, for example, integrating with AMR systems.
If tasks have the same status, we compare the time that status was set (so for example, if a task_0 was set to
RUNNINGat t=100s and a task_1 was set toRUNNINGat t=200s, task_0 will always be earlier in the queue.If tasks have a different status, they will be ordered in order of
RUNNING-QUEUED-ASSIGNED- others (FAILED,FINISHED, undefined values).Note that what really matters to make sure current behavior is preserved is that priority is respected when tasks are
RUNNING, all the other states are not so important. Specifically, the current behavior is that tasks that are running do so in a "FIFO" basis, so the first item that is asked to run will do so and, if other tasks are requested to run but the workcell is not able to perform parallel tasks, they will not preempt the currently running task until it is finished.This is ensured by the request time logic.
TODO:
context.hpp.