diff --git a/wpilibc/src/main/native/cpp/MotorSafety.cpp b/wpilibc/src/main/native/cpp/MotorSafety.cpp index d172a81142..44f0f86504 100644 --- a/wpilibc/src/main/native/cpp/MotorSafety.cpp +++ b/wpilibc/src/main/native/cpp/MotorSafety.cpp @@ -39,6 +39,8 @@ MotorSafety::MotorSafety(MotorSafety&& rhs) m_stopTime(std::move(rhs.m_stopTime)) {} MotorSafety& MotorSafety::operator=(MotorSafety&& rhs) { + std::scoped_lock lock(m_thisMutex, rhs.m_thisMutex); + ErrorBase::operator=(std::move(rhs)); m_expiration = std::move(rhs.m_expiration); diff --git a/wpilibc/src/main/native/cpp/Timer.cpp b/wpilibc/src/main/native/cpp/Timer.cpp index 8f0b09361e..285ff0945d 100644 --- a/wpilibc/src/main/native/cpp/Timer.cpp +++ b/wpilibc/src/main/native/cpp/Timer.cpp @@ -39,6 +39,21 @@ const double Timer::kRolloverTime = (1ll << 32) / 1e6; Timer::Timer() { Reset(); } +Timer::Timer(Timer&& rhs) + : m_startTime(std::move(rhs.m_startTime)), + m_accumulatedTime(std::move(rhs.m_accumulatedTime)), + m_running(std::move(rhs.m_running)) {} + +Timer& Timer::operator=(Timer&& rhs) { + std::scoped_lock lock(m_mutex, rhs.m_mutex); + + m_startTime = std::move(rhs.m_startTime); + m_accumulatedTime = std::move(rhs.m_accumulatedTime); + m_running = std::move(rhs.m_running); + + return *this; +} + double Timer::Get() const { double result; double currentTime = GetFPGATimestamp(); diff --git a/wpilibc/src/main/native/include/frc/Timer.h b/wpilibc/src/main/native/include/frc/Timer.h index 1b15e1405a..25f37c8322 100644 --- a/wpilibc/src/main/native/include/frc/Timer.h +++ b/wpilibc/src/main/native/include/frc/Timer.h @@ -56,8 +56,8 @@ class Timer { virtual ~Timer() = default; - Timer(Timer&&) = default; - Timer& operator=(Timer&&) = default; + Timer(Timer&& rhs); + Timer& operator=(Timer&& rhs); /** * Get the current time from the timer. If the clock is running it is derived