Add ability to run robot main loop in a separate thread (#1895)

Default behavior is still to run the robot main loop in the main thread.

The ability to run the robot main loop in a separate thread and add a hook
for running a different function in the main thread is needed for simulation
GUI support on some platforms.
This commit is contained in:
Peter Johnson
2019-09-28 15:43:24 -07:00
committed by GitHub
parent 457f94ba26
commit b23baf611a
12 changed files with 239 additions and 18 deletions

View File

@@ -17,6 +17,7 @@
#include "HALUtil.h"
#include "edu_wpi_first_hal_HAL.h"
#include "hal/DriverStation.h"
#include "hal/Main.h"
using namespace frc;
using namespace wpi::java;
@@ -35,6 +36,42 @@ Java_edu_wpi_first_hal_HAL_initialize
return HAL_Initialize(timeout, mode);
}
/*
* Class: edu_wpi_first_hal_HAL
* Method: hasMain
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_HAL_hasMain
(JNIEnv*, jclass)
{
return HAL_HasMain();
}
/*
* Class: edu_wpi_first_hal_HAL
* Method: runMain
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_HAL_runMain
(JNIEnv*, jclass)
{
HAL_RunMain();
}
/*
* Class: edu_wpi_first_hal_HAL
* Method: exitMain
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_HAL_exitMain
(JNIEnv*, jclass)
{
HAL_ExitMain();
}
/*
* Class: edu_wpi_first_hal_HAL
* Method: observeUserProgramStarting