template<typename T>
cubos::core::thread::Task class final

Provides a mechanism to access the results of asynchronous operations.

Template parameters
T Result type.

Constructors, destructors, conversion operators

Task()
Constructs.
Task(T value)
Constructs a finished task.
Task(const Task& other)
Copy constructs.
Task(Task&& other) noexcept
Move constructs.

Public functions

auto operator=(const Task& other) -> Task&
Copy assigns.
auto operator=(Task&& other) -> Task& noexcept
Move assigns.
void finish(T value)
Finishes the task, setting its result and notifying a waiting thread.
void discard()
Discards any result eventually received. The task is left in an invalid state.
auto isDone() const -> bool
Returns whether the task has finished.
auto result() -> T
Blocks until the task finishes and then returns its result.

Function documentation

template<typename T>
cubos::core::thread::Task<T>::Task(T value)

Constructs a finished task.

Parameters
value Task result.
Returns Task.

template<typename T>
cubos::core::thread::Task<T>::Task(const Task& other)

Copy constructs.

Parameters
other Task.

template<typename T>
cubos::core::thread::Task<T>::Task(Task&& other) noexcept

Move constructs.

Parameters
other Task.

template<typename T>
Task& cubos::core::thread::Task<T>::operator=(const Task& other)

Copy assigns.

Parameters
other Task.

template<typename T>
Task& cubos::core::thread::Task<T>::operator=(Task&& other) noexcept

Move assigns.

Parameters
other Task.

template<typename T>
void cubos::core::thread::Task<T>::finish(T value)

Finishes the task, setting its result and notifying a waiting thread.

Parameters
value Task result.

template<typename T>
bool cubos::core::thread::Task<T>::isDone() const

Returns whether the task has finished.

Returns Whether the task has finished.

template<typename T>
T cubos::core::thread::Task<T>::result()

Blocks until the task finishes and then returns its result.

Returns Task result.