blob: 7b1e647c7c2dbe01ff5f3604e9b8922c8ec899eb [file] [log] [blame]
Brian Silverman8fce7482020-01-05 13:18:21 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
6/*----------------------------------------------------------------------------*/
7
8#include "frc/Threads.h"
9
10#include <hal/FRCUsageReporting.h>
11#include <hal/Threads.h>
12
13#include "frc/ErrorBase.h"
14
15namespace frc {
16
17int GetThreadPriority(std::thread& thread, bool* isRealTime) {
18 int32_t status = 0;
19 HAL_Bool rt = false;
20 auto native = thread.native_handle();
21 auto ret = HAL_GetThreadPriority(&native, &rt, &status);
22 wpi_setGlobalHALError(status);
23 *isRealTime = rt;
24 return ret;
25}
26
27int GetCurrentThreadPriority(bool* isRealTime) {
28 int32_t status = 0;
29 HAL_Bool rt = false;
30 auto ret = HAL_GetCurrentThreadPriority(&rt, &status);
31 wpi_setGlobalHALError(status);
32 *isRealTime = rt;
33 return ret;
34}
35
36bool SetThreadPriority(std::thread& thread, bool realTime, int priority) {
37 int32_t status = 0;
38 auto native = thread.native_handle();
39 auto ret = HAL_SetThreadPriority(&native, realTime, priority, &status);
40 wpi_setGlobalHALError(status);
41 return ret;
42}
43
44bool SetCurrentThreadPriority(bool realTime, int priority) {
45 int32_t status = 0;
46 auto ret = HAL_SetCurrentThreadPriority(realTime, priority, &status);
47 wpi_setGlobalHALError(status);
48 return ret;
49}
50
51} // namespace frc