Class any_executor

Class Documentation

class concore::v1::any_executor

A polymorphic executor wrapper.

This provides a type erasure on an executor type. It can hold any type of executor object in it and wraps its execution. The type of the wrapped object must model the executor concept.

If the any executor is is not initialized with a valid executor, then calling execute() on it is undefined behavior.

See

executor, inline_executor, global_executor

Public Functions

any_executor() noexcept = default

Constructs an invalid executor.

any_executor(std::nullptr_t) noexcept

Constructs an invalid executor.

any_executor(const any_executor &other) noexcept

Copy constructor.

any_executor(any_executor &&other) noexcept

Move constructor.

template<typename Executor>
any_executor(Executor e)

Constructor from a valid executor.

This will construct the object by wrapping the given executor. The given executor must be valid and must model the

executor concept.
Parameters
  • e: The executor to be wrapped by this object

See

executor

any_executor &operator=(const any_executor &other) noexcept

Copy assignment.

any_executor &operator=(any_executor &&other) noexcept

Move assignment.

any_executor &operator=(std::nullptr_t) noexcept

Copy assignment from nullptr_t.

template<typename Executor>
any_executor &operator=(Executor e)

Assignment operator from another executor.

This will implement assignment from another executor. The given executor must be valid and must model the

executor concept.
Return

Reference to this object

Parameters
  • e: The executor to be wrapped in this object

See

executor

~any_executor()

Destructor.

void swap(any_executor &other) noexcept

Swaps the content of this object with the content of the given object.

template<typename F>
void execute(F &&f) const

The main execution method of this executor.

This implements the

execute() CPO for this executor object, making it conform to the executor concept. It forwards the call to the underlying executor.
Parameters
  • f: Functor to be executed in the wrapped executor

See

executor

void execute(task t) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

operator bool() const noexcept

Checks if this executor is wrapping another executor.

const std::type_info &target_type() const noexcept

Returns the type_info for the wrapped executor type.

template<typename Executor>
Executor *target() noexcept

Helper method to get the underlying executor, if its type is specified.

template<typename Executor>
const Executor *target() const noexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Friends

friend bool operator==(any_executor l, any_executor r)

Equality operator.

friend bool operator==(any_executor l, std::nullptr_t)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

friend bool operator==(std::nullptr_t, any_executor r)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

friend bool operator!=(any_executor l, any_executor r)

Inequality operator.

friend bool operator!=(any_executor l, std::nullptr_t r)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

friend bool operator!=(std::nullptr_t l, any_executor r)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.