summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/score/threadqimpl.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-05-18 12:50:41 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-05-18 18:47:43 +0200
commita89ecaa1a94d49ddae7753d6b83923e9d2a00486 (patch)
tree2fccf3fd6b5a82f0415b497db190fbfa582a3866 /cpukit/include/rtems/score/threadqimpl.h
parentposix: Fix use of clock for relative times (diff)
downloadrtems-a89ecaa1a94d49ddae7753d6b83923e9d2a00486.tar.bz2
score: Simplify thread queue timeout handling
Add Thread_queue_Context::timeout_absolute to specify an absolute or relative timeout. This avoid having to get the current time twice for timeouts relative to the current time. It moves also functionality to common code.
Diffstat (limited to 'cpukit/include/rtems/score/threadqimpl.h')
-rw-r--r--cpukit/include/rtems/score/threadqimpl.h36
1 files changed, 24 insertions, 12 deletions
diff --git a/cpukit/include/rtems/score/threadqimpl.h b/cpukit/include/rtems/score/threadqimpl.h
index ca59de9e31..7b00de009d 100644
--- a/cpukit/include/rtems/score/threadqimpl.h
+++ b/cpukit/include/rtems/score/threadqimpl.h
@@ -267,41 +267,53 @@ _Thread_queue_Context_set_enqueue_timeout_ticks(
}
/**
- * @brief Sets the enqueue callout to add an absolute monotonic timeout in
- * timespec format.
+ * @brief Sets the enqueue callout to add a timeout in timespec format using
+ * CLOCK_MONOTONIC.
*
- * @param[out] queue_context The thread queue context.
- * @param abstime The absolute monotonic timeout.
+ * @param[out] queue_context is the thread queue context.
+ *
+ * @param timeout is the absolute or relative timeout.
+ *
+ * @param absolute is true, if the timeout shall be absolute, otherwise it
+ * shall be relative to the current time of the clock.
*
* @see _Thread_queue_Enqueue().
*/
RTEMS_INLINE_ROUTINE void
_Thread_queue_Context_set_enqueue_timeout_monotonic_timespec(
Thread_queue_Context *queue_context,
- const struct timespec *abstime
+ const struct timespec *timeout,
+ bool absolute
)
{
- queue_context->Timeout.arg = abstime;
+ queue_context->Timeout.arg = timeout;
+ queue_context->timeout_absolute = absolute;
queue_context->enqueue_callout =
_Thread_queue_Add_timeout_monotonic_timespec;
}
/**
- * @brief Sets the enqueue callout to add an absolute realtime timeout in
- * timespec format.
+ * @brief Sets the enqueue callout to add a timeout in timespec format using
+ * CLOCK_REALTIME.
*
- * @param[out] queue_context The thread queue context.
- * @param abstime The absolute realtime timeout.
+ * @param[out] queue_context is the thread queue context.
+ *
+ * @param timeout is the absolute or relative timeout.
+ *
+ * @param absolute is true, if the timeout shall be absolute, otherwise it
+ * shall be relative to the current time of the clock.
*
* @see _Thread_queue_Enqueue().
*/
RTEMS_INLINE_ROUTINE void
_Thread_queue_Context_set_enqueue_timeout_realtime_timespec(
Thread_queue_Context *queue_context,
- const struct timespec *abstime
+ const struct timespec *timeout,
+ bool absolute
)
{
- queue_context->Timeout.arg = abstime;
+ queue_context->Timeout.arg = timeout;
+ queue_context->timeout_absolute = absolute;
queue_context->enqueue_callout = _Thread_queue_Add_timeout_realtime_timespec;
}