mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Fix notifier race happening with very fast notifiers (#2370)
What would happen is the Stop() call would happen between the notifier loop being triggered and calling UpdateAlarm(). This would cause the Update to overwrite the stop.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2020 FIRST. All Rights Reserved. */
|
||||
/* 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. */
|
||||
@@ -207,6 +207,12 @@ public class Notifier implements AutoCloseable {
|
||||
* function will block until the handler call is complete.
|
||||
*/
|
||||
public void stop() {
|
||||
NotifierJNI.cancelNotifierAlarm(m_notifier.get());
|
||||
m_processLock.lock();
|
||||
try {
|
||||
m_periodic = false;
|
||||
NotifierJNI.cancelNotifierAlarm(m_notifier.get());
|
||||
} finally {
|
||||
m_processLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user