Commit c8934bf3 authored by Xavier Thompson's avatar Xavier Thompson

Add move constructor/assignment for task.hpp

parent f1c7873f
......@@ -19,14 +19,24 @@ namespace typon::rt
Task(std::coroutine_handle<promise_type> coroutine) noexcept : _coroutine(coroutine) {}
Task(const Task &) = delete;
Task(Task &&) = delete;
Task & operator=(const Task &) = delete;
Task & operator=(Task &&) = delete;
Task(Task && other) noexcept
: _coroutine(std::exchange(other._coroutine, nullptr))
{}
Task & operator=(Task other)
{
std::swap(_coroutine, other._coroutine);
return *this;
}
~Task()
{
_coroutine.destroy();
if (_coroutine)
{
_coroutine.destroy();
}
}
struct promise_type : Result<T>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment