Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit move constructor / move assignment for task in shared_ta… #1

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions include/async++/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,17 @@ class shared_task: public detail::basic_task<Result> {
// Movable and copyable
shared_task() = default;

// Move constructor for task
shared_task(task<Result>&& other) LIBASYNC_NOEXCEPT
: detail::basic_task<Result>(std::move(other)) {}

// Move-assignment for task
shared_task& operator=(task<Result>&& other) LIBASYNC_NOEXCEPT
{
detail::basic_task<Result>::operator=(std::move(other));
return *this;
}

// Get the result of the task
get_result get() const
{
Expand Down
4 changes: 2 additions & 2 deletions include/async++/task_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ struct LIBASYNC_CACHELINE_ALIGN task_base: public ref_count_base<task_base, task
std::atomic<task_state> state;

// Whether get_task() was already called on an event_task
bool event_task_got_task;
bool event_task_got_task{};

// Vector of continuations
continuation_vector continuations;

// Virtual function table used for dynamic dispatch
const task_base_vtable* vtable;
const task_base_vtable* vtable{};

// Use aligned memory allocation
static void* operator new(std::size_t size)
Expand Down