mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Add move constructors and assignment operators to wpilibc (#1314)
Fixes #898.
This commit is contained in:
committed by
Peter Johnson
parent
b1965f74a8
commit
1aa8446725
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "frc/Notifier.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/Timer.h"
|
||||
@@ -63,6 +65,31 @@ Notifier::~Notifier() {
|
||||
HAL_CleanNotifier(handle, &status);
|
||||
}
|
||||
|
||||
Notifier::Notifier(Notifier&& rhs)
|
||||
: ErrorBase(std::move(rhs)),
|
||||
m_thread(std::move(rhs.m_thread)),
|
||||
m_notifier(rhs.m_notifier.load()),
|
||||
m_handler(std::move(rhs.m_handler)),
|
||||
m_expirationTime(std::move(rhs.m_expirationTime)),
|
||||
m_period(std::move(rhs.m_period)),
|
||||
m_periodic(std::move(rhs.m_periodic)) {
|
||||
rhs.m_notifier = HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
Notifier& Notifier::operator=(Notifier&& rhs) {
|
||||
ErrorBase::operator=(std::move(rhs));
|
||||
|
||||
m_thread = std::move(rhs.m_thread);
|
||||
m_notifier = rhs.m_notifier.load();
|
||||
rhs.m_notifier = HAL_kInvalidHandle;
|
||||
m_handler = std::move(rhs.m_handler);
|
||||
m_expirationTime = std::move(rhs.m_expirationTime);
|
||||
m_period = std::move(rhs.m_period);
|
||||
m_periodic = std::move(rhs.m_periodic);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Notifier::SetHandler(TimerEventHandler handler) {
|
||||
std::lock_guard<wpi::mutex> lock(m_processMutex);
|
||||
m_handler = handler;
|
||||
|
||||
Reference in New Issue
Block a user