Add move constructors and assignment operators to wpilibc (#1314)

Fixes #898.
This commit is contained in:
Tyler Veness
2018-09-24 00:08:25 -07:00
committed by Peter Johnson
parent b1965f74a8
commit 1aa8446725
136 changed files with 764 additions and 89 deletions

View File

@@ -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;