2016-12-01 21:06:19 -08:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2019-09-06 18:42:40 -07:00
|
|
|
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
|
2016-12-01 21:06:19 -08:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include <jni.h>
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
#include <cassert>
|
2016-12-01 21:06:19 -08:00
|
|
|
|
|
|
|
|
#include "HALUtil.h"
|
2018-09-20 21:59:46 -07:00
|
|
|
#include "edu_wpi_first_hal_ThreadsJNI.h"
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "hal/Threads.h"
|
2016-12-01 21:06:19 -08:00
|
|
|
|
|
|
|
|
using namespace frc;
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
/*
|
2018-09-20 21:59:46 -07:00
|
|
|
* Class: edu_wpi_first_hal_ThreadsJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: getCurrentThreadPriority
|
2016-12-01 21:06:19 -08:00
|
|
|
* Signature: ()I
|
|
|
|
|
*/
|
2018-05-13 17:09:56 -07:00
|
|
|
JNIEXPORT jint JNICALL
|
2018-09-20 21:59:46 -07:00
|
|
|
Java_edu_wpi_first_hal_ThreadsJNI_getCurrentThreadPriority
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass)
|
|
|
|
|
{
|
2016-12-01 21:06:19 -08:00
|
|
|
int32_t status = 0;
|
|
|
|
|
HAL_Bool isRT = false;
|
|
|
|
|
auto ret = HAL_GetCurrentThreadPriority(&isRT, &status);
|
|
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return (jint)ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2018-09-20 21:59:46 -07:00
|
|
|
* Class: edu_wpi_first_hal_ThreadsJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: getCurrentThreadIsRealTime
|
2016-12-01 21:06:19 -08:00
|
|
|
* Signature: ()Z
|
|
|
|
|
*/
|
2018-05-13 17:09:56 -07:00
|
|
|
JNIEXPORT jboolean JNICALL
|
2018-09-20 21:59:46 -07:00
|
|
|
Java_edu_wpi_first_hal_ThreadsJNI_getCurrentThreadIsRealTime
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass)
|
|
|
|
|
{
|
2016-12-01 21:06:19 -08:00
|
|
|
int32_t status = 0;
|
|
|
|
|
HAL_Bool isRT = false;
|
|
|
|
|
HAL_GetCurrentThreadPriority(&isRT, &status);
|
|
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return (jboolean)isRT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2018-09-20 21:59:46 -07:00
|
|
|
* Class: edu_wpi_first_hal_ThreadsJNI
|
2018-05-13 17:09:56 -07:00
|
|
|
* Method: setCurrentThreadPriority
|
2016-12-01 21:06:19 -08:00
|
|
|
* Signature: (ZI)Z
|
|
|
|
|
*/
|
2018-05-13 17:09:56 -07:00
|
|
|
JNIEXPORT jboolean JNICALL
|
2018-09-20 21:59:46 -07:00
|
|
|
Java_edu_wpi_first_hal_ThreadsJNI_setCurrentThreadPriority
|
2018-05-13 17:09:56 -07:00
|
|
|
(JNIEnv* env, jclass, jboolean realTime, jint priority)
|
|
|
|
|
{
|
2016-12-01 21:06:19 -08:00
|
|
|
int32_t status = 0;
|
2018-05-13 17:09:56 -07:00
|
|
|
auto ret = HAL_SetCurrentThreadPriority(
|
|
|
|
|
(HAL_Bool)realTime, static_cast<int32_t>(priority), &status);
|
2016-12-01 21:06:19 -08:00
|
|
|
CheckStatus(env, status);
|
|
|
|
|
return (jboolean)ret;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
} // extern "C"
|