Files
allwpilib/cscore/src/main/native/linux/RunLoopHelpers.cpp

40 lines
848 B
C++
Raw Normal View History

// 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.
2025-11-07 19:56:21 -05:00
#include "wpi/util/Synchronization.h"
2025-11-07 19:56:21 -05:00
#include "wpi/cs/cscore_runloop.hpp"
static wpi::Event& GetInstance() {
static wpi::Event event;
return event;
}
namespace cs {
void RunMainRunLoop() {
wpi::Event& event = GetInstance();
wpi::WaitForObject(event.GetHandle());
}
int RunMainRunLoopTimeout(double timeout) {
wpi::Event& event = GetInstance();
bool timedOut = false;
bool signaled = wpi::WaitForObject(event.GetHandle(), timeout, &timedOut);
if (timedOut) {
return 3;
}
if (signaled) {
return 2;
}
return 1;
}
void StopMainRunLoop() {
wpi::Event& event = GetInstance();
event.Set();
}
} // namespace cs