mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Force a DS mutex release on shutdown on desktop (#1188)
This fixes some issues with freezing tests.
This commit is contained in:
committed by
Peter Johnson
parent
76c901ce78
commit
7f000fecc4
@@ -27,6 +27,7 @@ static wpi::mutex msgMutex;
|
||||
static wpi::condition_variable* newDSDataAvailableCond;
|
||||
static wpi::mutex newDSDataAvailableMutex;
|
||||
static int newDSDataAvailableCounter{0};
|
||||
static std::atomic_bool isFinalized{false};
|
||||
|
||||
namespace hal {
|
||||
namespace init {
|
||||
@@ -234,6 +235,9 @@ HAL_Bool HAL_IsNewControlData(void) {
|
||||
void HAL_WaitForDSData(void) { HAL_WaitForDSDataTimeout(0); }
|
||||
|
||||
HAL_Bool HAL_WaitForDSDataTimeout(double timeout) {
|
||||
if (isFinalized.load()) {
|
||||
return false;
|
||||
}
|
||||
auto timeoutTime =
|
||||
std::chrono::steady_clock::now() + std::chrono::duration<double>(timeout);
|
||||
|
||||
@@ -279,6 +283,11 @@ void HAL_InitializeDriverStation(void) {
|
||||
|
||||
SimDriverStationData->ResetData();
|
||||
|
||||
std::atexit([]() {
|
||||
isFinalized.store(true);
|
||||
HAL_ReleaseDSMutex();
|
||||
});
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user