encoding+util: ensure move constructors are properly declared
This also fixes a race condition in scheduler::EventId::operator bool()
Change-Id: I468f0c46039a3d1a38c69c419ae45b4445d8205a
Refs: #3414
diff --git a/src/util/scheduler-scoped-event-id.cpp b/src/util/scheduler-scoped-event-id.cpp
index 0ca7d13..d83fa4c 100644
--- a/src/util/scheduler-scoped-event-id.cpp
+++ b/src/util/scheduler-scoped-event-id.cpp
@@ -25,34 +25,24 @@
namespace util {
namespace scheduler {
-static_assert(std::is_nothrow_move_constructible<ScopedEventId>::value,
- "ScopedEventId must be MoveConstructible with noexcept");
-
-ScopedEventId::ScopedEventId(Scheduler& scheduler)
+ScopedEventId::ScopedEventId(Scheduler& scheduler) noexcept
: m_scheduler(&scheduler)
{
}
-ScopedEventId::ScopedEventId(ScopedEventId&& other) noexcept
- : m_scheduler(other.m_scheduler)
- , m_event(other.m_event)
-{
- other.release();
-}
-
ScopedEventId&
-ScopedEventId::operator=(const EventId& event)
+ScopedEventId::operator=(EventId event)
{
if (m_event != event) {
- m_scheduler->cancelEvent(m_event);
- m_event = event;
+ cancel();
+ m_event = std::move(event);
}
return *this;
}
-ScopedEventId::~ScopedEventId() noexcept
+ScopedEventId::~ScopedEventId()
{
- m_scheduler->cancelEvent(m_event);
+ cancel();
}
void