diff --git a/src/dsl/word/Priority.hpp b/src/dsl/word/Priority.hpp index 7b10853a..1c6ee715 100644 --- a/src/dsl/word/Priority.hpp +++ b/src/dsl/word/Priority.hpp @@ -32,36 +32,24 @@ namespace dsl { /** * Task priority can be controlled using an assigned setting. * - * @code on, Priority::HIGH>() @endcode + * @code on, Priority>() @endcode * The PowerPlant uses this setting to determine the scheduling order in the threadpool, as well as assign a * priority to the thread on the OS. * * The available priority settings are: * - * REALTIME: Tasks assigned with this will be queued with all other REALTIME tasks. - * + * HIGHEST: * HIGH: - * Tasks assigned with this will be queued with all other HIGH tasks. - * They will be scheduled for execution when there are no REALTIME tasks in the queue. - * * NORMAL: - * Tasks assigned with this will be queued with all other NORMAL tasks. - * They will be scheduled for execution when there are no REALTIME and HIGH tasks in the queue. - * * LOW: - * Tasks assigned with this will be queued with all other LOW tasks. - * They will be scheduled for execution when there are no REALTIME, HIGH and NORMAL tasks in the queue. - * - * IDLE: - * Tasks assigned with this priority will be queued with all other IDLE tasks. - * They will be scheduled for execution when there are no other tasks running in the system. + * LOWEST: * * @par Default Behaviour * @code on>() @endcode * When the priority is not specified, tasks will be assigned a default setting; NORMAL. * * @attention - * If the OS allows the user to set thread priority, this word can also be used to assign the priority of the + * If the OS allows the user to set thread priority, this word will also be used to assign the priority of the * thread in its runtime environment. * * @par Implements diff --git a/src/util/Priority.hpp b/src/util/Priority.hpp index 32348aa8..6e578181 100644 --- a/src/util/Priority.hpp +++ b/src/util/Priority.hpp @@ -30,13 +30,18 @@ namespace NUClear { namespace util { + /** + * The priority value for Priority dsl word + */ enum class Priority : uint8_t { LOWEST = 0, LOW = 1, NORMAL = 2, HIGH = 3, HIGHEST = 4 }; + /** + * Gets one lower priority unless already lowest + */ inline Priority prev(Priority value) { value = static_cast(static_cast>(value) - 1); value = std::min(value, Priority::LOWEST); return value; } - constexpr Priority MAX_PRIORITY = Priority::HIGHEST; } // namespace util } // namespace NUClear diff --git a/src/util/update_current_thread_priority.hpp b/src/util/update_current_thread_priority.hpp index 1aa6e52d..940d86a3 100644 --- a/src/util/update_current_thread_priority.hpp +++ b/src/util/update_current_thread_priority.hpp @@ -33,7 +33,7 @@ inline void update_current_thread_priority(NUClear::util::Priority priority) { auto priority_int = static_cast>(priority); auto step = (sched_get_priority_max(SCHED_RR) - sched_get_priority_min(SCHED_RR)) - / static_cast>(NUClear::util::MAX_PRIORITY); + / static_cast>(NUClear::util::Priority::HIGHEST); auto sched_priority = priority_int * step; sched_param p{};