mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Fix some move constructors (#1754)
Timer didn't have working move semantics because mutexes aren't moveable, meaning the default implementations were ill-formed. MotorSafety wasn't locking its mutex.
This commit is contained in:
committed by
Peter Johnson
parent
8757bc471b
commit
e582518bae
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user