WPILibC++ 2024.3.2
Threads.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include "hal/Types.h"
8
9/**
10 * @defgroup hal_threads Threads Functions
11 * @ingroup hal_capi
12 * @{
13 */
14
15typedef const void* NativeThreadHandle;
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21/**
22 * Gets the thread priority for the specified thread.
23 *
24 * @param[in] handle Native handle pointer to the thread to get the
25 * priority for.
26 * @param[out] isRealTime Set to true if thread is real-time, otherwise false.
27 * @param[out] status Error status variable. 0 on success.
28 * @return The current thread priority. For real-time, this is 1-99 with 99
29 * being highest. For non-real-time, this is 0. See "man 7 sched" for
30 * details.
31 */
33 int32_t* status);
34
35/**
36 * Gets the thread priority for the current thread.
37 *
38 * @param[out] isRealTime Set to true if thread is real-time, otherwise false.
39 * @param[out] status Error status variable. 0 on success.
40 * @return The current thread priority. For real-time, this is 1-99 with 99
41 * being highest. For non-real-time, this is 0. See "man 7 sched" for
42 * details.
43 */
44int32_t HAL_GetCurrentThreadPriority(HAL_Bool* isRealTime, int32_t* status);
45
46/**
47 * Sets the thread priority for the specified thread.
48 *
49 * @param[in] handle Reference to the thread to set the priority of.
50 * @param[in] realTime Set to true to set a real-time priority, false for
51 * standard priority.
52 * @param[in] priority Priority to set the thread to. For real-time, this is
53 * 1-99 with 99 being highest. For non-real-time, this is
54 * forced to 0. See "man 7 sched" for more details.
55 * @param[out] status Error status variable. 0 on success.
56 * @return True on success.
57 */
59 int32_t priority, int32_t* status);
60
61/**
62 * Sets the thread priority for the current thread.
63 *
64 * @param[in] realTime Set to true to set a real-time priority, false for
65 * standard priority.
66 * @param[in] priority Priority to set the thread to. For real-time, this is
67 * 1-99 with 99 being highest. For non-real-time, this is
68 * forced to 0. See "man 7 sched" for more details.
69 * @param[out] status Error status variable. 0 on success.
70 * @return True on success.
71 */
73 int32_t* status);
74
75#ifdef __cplusplus
76} // extern "C"
77#endif
78/** @} */
HAL_Bool HAL_SetThreadPriority(NativeThreadHandle handle, HAL_Bool realTime, int32_t priority, int32_t *status)
Sets the thread priority for the specified thread.
int32_t HAL_GetCurrentThreadPriority(HAL_Bool *isRealTime, int32_t *status)
Gets the thread priority for the current thread.
int32_t HAL_GetThreadPriority(NativeThreadHandle handle, HAL_Bool *isRealTime, int32_t *status)
Gets the thread priority for the specified thread.
HAL_Bool HAL_SetCurrentThreadPriority(HAL_Bool realTime, int32_t priority, int32_t *status)
Sets the thread priority for the current thread.
const void * NativeThreadHandle
Definition: Threads.h:15
int32_t HAL_Bool
Definition: Types.h:73