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 <thread>
8
9namespace frc {
10
11/**
12 * Get the thread priority for the specified thread.
13 *
14 * @param thread Reference to the thread to get the priority for.
15 * @param isRealTime Set to true if thread is real-time, otherwise false.
16 * @return The current thread priority. For real-time, this is 1-99
17 * with 99 being highest. For non-real-time, this is 0. See
18 * "man 7 sched" for details.
19 */
20int GetThreadPriority(std::thread& thread, bool* isRealTime);
21
22/**
23 * Get the thread priority for the current thread.
24 *
25 * @param isRealTime Set to true if thread is real-time, otherwise false.
26 * @return The current thread priority. For real-time, this is 1-99
27 * with 99 being highest. For non-real-time, this is 0. See
28 * "man 7 sched" for details.
29 */
30int GetCurrentThreadPriority(bool* isRealTime);
31
32/**
33 * Sets the thread priority for the specified thread.
34 *
35 * @param thread Reference to the thread to set the priority of.
36 * @param realTime Set to true to set a real-time priority, false for standard
37 * priority.
38 * @param priority Priority to set the thread to. For real-time, this is 1-99
39 * with 99 being highest. For non-real-time, this is forced to
40 * 0. See "man 7 sched" for more details.
41 * @return True on success.
42 */
43bool SetThreadPriority(std::thread& thread, bool realTime, int priority);
44
45/**
46 * Sets the thread priority for the current thread.
47 *
48 * @param realTime Set to true to set a real-time priority, false for standard
49 * priority.
50 * @param priority Priority to set the thread to. For real-time, this is 1-99
51 * with 99 being highest. For non-real-time, this is forced to
52 * 0. See "man 7 sched" for more details.
53 * @return True on success.
54 */
55bool SetCurrentThreadPriority(bool realTime, int priority);
56
57} // namespace frc
Definition: AprilTagPoseEstimator.h:15
int GetThreadPriority(std::thread &thread, bool *isRealTime)
Get the thread priority for the specified thread.
int GetCurrentThreadPriority(bool *isRealTime)
Get the thread priority for the current thread.
bool SetCurrentThreadPriority(bool realTime, int priority)
Sets the thread priority for the current thread.
bool SetThreadPriority(std::thread &thread, bool realTime, int priority)
Sets the thread priority for the specified thread.