diff --git a/wpilibc/src/main/native/cpp/Notifier.cpp b/wpilibc/src/main/native/cpp/Notifier.cpp index a7fa0381bd..3065e655cd 100644 --- a/wpilibc/src/main/native/cpp/Notifier.cpp +++ b/wpilibc/src/main/native/cpp/Notifier.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-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. */ @@ -129,6 +129,8 @@ void Notifier::StartPeriodic(units::second_t period) { } void Notifier::Stop() { + std::scoped_lock lock(m_processMutex); + m_periodic = false; int32_t status = 0; HAL_CancelNotifierAlarm(m_notifier, &status); wpi_setHALError(status); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Notifier.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Notifier.java index 806bfa9899..546da5b836 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Notifier.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Notifier.java @@ -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(); + } } }