2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2016-12-01 21:06:19 -08:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
|
|
namespace frc {
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Get the thread priority for the specified thread.
|
|
|
|
|
*
|
|
|
|
|
* @param thread Reference to the thread to get the priority for.
|
2021-01-19 22:59:18 -08:00
|
|
|
* @param isRealTime Set to true if thread is real-time, otherwise false.
|
|
|
|
|
* @return The current thread priority. For real-time, this is 1-99
|
|
|
|
|
* with 99 being highest. For non-real-time, this is 0. See
|
|
|
|
|
* "man 7 sched" for details.
|
2018-05-31 20:47:15 -07:00
|
|
|
*/
|
2016-12-01 21:06:19 -08:00
|
|
|
int GetThreadPriority(std::thread& thread, bool* isRealTime);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
2021-08-14 11:42:35 -07:00
|
|
|
* Get the thread priority for the current thread.
|
2018-05-31 20:47:15 -07:00
|
|
|
*
|
2021-01-19 22:59:18 -08:00
|
|
|
* @param isRealTime Set to true if thread is real-time, otherwise false.
|
|
|
|
|
* @return The current thread priority. For real-time, this is 1-99
|
|
|
|
|
* with 99 being highest. For non-real-time, this is 0. See
|
|
|
|
|
* "man 7 sched" for details.
|
2018-05-31 20:47:15 -07:00
|
|
|
*/
|
2016-12-01 21:06:19 -08:00
|
|
|
int GetCurrentThreadPriority(bool* isRealTime);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
2021-08-14 11:42:35 -07:00
|
|
|
* Sets the thread priority for the specified thread.
|
2018-05-31 20:47:15 -07:00
|
|
|
*
|
|
|
|
|
* @param thread Reference to the thread to set the priority of.
|
2021-01-19 22:59:18 -08:00
|
|
|
* @param realTime Set to true to set a real-time priority, false for standard
|
2018-05-31 20:47:15 -07:00
|
|
|
* priority.
|
2021-01-19 22:59:18 -08:00
|
|
|
* @param priority Priority to set the thread to. For real-time, this is 1-99
|
|
|
|
|
* with 99 being highest. For non-real-time, this is forced to
|
|
|
|
|
* 0. See "man 7 sched" for more details.
|
|
|
|
|
* @return True on success.
|
2018-05-31 20:47:15 -07:00
|
|
|
*/
|
2016-12-01 21:06:19 -08:00
|
|
|
bool SetThreadPriority(std::thread& thread, bool realTime, int priority);
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
2021-08-14 11:42:35 -07:00
|
|
|
* Sets the thread priority for the current thread.
|
2018-05-31 20:47:15 -07:00
|
|
|
*
|
2021-01-19 22:59:18 -08:00
|
|
|
* @param realTime Set to true to set a real-time priority, false for standard
|
2018-05-31 20:47:15 -07:00
|
|
|
* priority.
|
2021-01-19 22:59:18 -08:00
|
|
|
* @param priority Priority to set the thread to. For real-time, this is 1-99
|
|
|
|
|
* with 99 being highest. For non-real-time, this is forced to
|
|
|
|
|
* 0. See "man 7 sched" for more details.
|
|
|
|
|
* @return True on success.
|
2018-05-31 20:47:15 -07:00
|
|
|
*/
|
2016-12-01 21:06:19 -08:00
|
|
|
bool SetCurrentThreadPriority(bool realTime, int priority);
|
2017-08-23 22:07:46 -07:00
|
|
|
|
2016-12-01 21:06:19 -08:00
|
|
|
} // namespace frc
|