mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
Places while loop around DS wait condition. (#83)
In case of Spontaneous wake ups, we should be checking a condition variable as well. Note that we can not use the existing m_newControlData, as that has a possible race condition with existing user code that it does not look like we could work around.
This commit is contained in:
committed by
Peter Johnson
parent
ed7d2d6aa6
commit
c622c03eff
@@ -80,6 +80,10 @@ void DriverStation::Run() {
|
||||
m_packetDataAvailableCond.wait(lock);
|
||||
}
|
||||
GetData();
|
||||
{
|
||||
std::lock_guard<priority_mutex> lock(m_waitForDataMutex);
|
||||
m_updatedControlLoopData = true;
|
||||
}
|
||||
m_waitForDataCond.notify_all();
|
||||
|
||||
if (++period >= 4) {
|
||||
@@ -554,7 +558,10 @@ uint32_t DriverStation::GetLocation() const {
|
||||
*/
|
||||
void DriverStation::WaitForData() {
|
||||
std::unique_lock<priority_mutex> lock(m_waitForDataMutex);
|
||||
m_waitForDataCond.wait(lock);
|
||||
while (!m_updatedControlLoopData) {
|
||||
m_waitForDataCond.wait(lock);
|
||||
}
|
||||
m_updatedControlLoopData = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user