Template Class Future

Class Documentation

template<typename T>
class Future

A task in a given pool which will eventually resolve to a result.

Public Functions

void await()

Block until execution has completed, successfully or not.

Status checkStatus() const noexcept

Get the status of a future.

Returns:

The future’s current status

template<typename F, typename ...ExArgs, typename R = std::invoke_result_t<F&&, T, ExArgs&&...>>
Future<R> then(F &&func, ExArgs&&... exargs)

Schedule a tracked task for execution after this future.

Template Parameters:
  • F – Function type

  • ExArgs – Arguments to the function

  • R – Function return type

Parameters:
  • func – The function to invoke

  • exargs – Extra arguments to pass to the function

Throws:
  • std::logic_error – If the task fails

  • std::bad_weak_ptr – If the pool to which this future belongs no longer exists

template<typename F, typename ...ExArgs>
void thenDetached(F &&func, ExArgs&&... exargs)

Schedule a tracked task for execution after this future with no result.

Template Parameters:
  • F – Function type

  • ExArgs – Extra arguments to the function

Parameters:
  • func – The function to invoke

  • exargs – Extra arguments to pass to the function

Throws:
  • std::logic_error – If the task fails

  • std::bad_weak_ptr – If the pool to which this future belongs no longer exists

template<std::ranges::input_range Rn, typename F, typename ...ExArgs, typename I = std::ranges::range_value_t<Rn>, typename R = std::invoke_result_t<F&&, T, I, ExArgs&&...>>
MultiFuture<R> thenBatch(Rn &&src, F &&func, ExArgs&&... exargs)

Schedule a tracked batch job based on a container for execution after this future.

Template Parameters:
  • Rn – Source data container type

  • I – Type of elements in container

  • F – Function type

  • ExArgs – Extra arguments to the function

  • R – Function return type

Parameters:
  • src – The source range to iterate over

  • func – The function to invoke

  • exargs – Extra arguments to pass to the function

Throws:
  • std::logic_error – If the task fails

  • std::bad_weak_ptr – If the pool to which this future belongs no longer exists

template<std::ranges::input_range Rn, typename F, typename ...ExArgs, typename I = std::ranges::range_value_t<Rn>>
void thenBatchDetached(Rn &&src, F &&func, ExArgs&&... exargs)

Schedule a batch job based on a container for execution after this future with no result.

Template Parameters:
  • Rn – Source data container type

  • I – Type of elements in container

  • F – Function type

  • ExArgs – Extra arguments to the function

Parameters:
  • src – The source range to iterate over

  • func – The function to invoke

  • exargs – Extra arguments to pass to the function

Throws:
  • std::logic_error – If the task fails

  • std::bad_weak_ptr – If the pool to which this future belongs no longer exists

T &operator*()

Obtain the task result, blocking if not complete.

This function does not exist in the void specialization of this type

Throws:

The – exception thrown by the task if failed

Returns:

The result of the task

T operator*() const

Obtain the task result, blocking if not complete.

This function does not exist in the void specialization of this type

Throws:

The – exception thrown by the task if failed

Returns:

The result of the task

T *operator->()

Obtain the task result, blocking if not complete.

This function does not exist in the void specialization of this type

Throws:

The – exception thrown by the task if failed

Returns:

The result of the task

const T *operator->() const

Obtain the task result, blocking if not complete.

This function does not exist in the void specialization of this type

Throws:

The – exception thrown by the task if failed

Returns:

The result of the task