← API Reference Namespace

asge::concurrent

Namespaces

Classes & Structs

Enumerations

#enum class ContextErr
Nil
Canceled
Deadline

Typedefs

#using context_pointer = _internal::IContext::pointer
#using thread_pointer = Thread::thread_pointer

Functions

#std::string CtxErrStr(ContextErr inErr) noexcept
#template<typename T> std::shared_ptr< ContextWithValue< T > > WithValue(T inValue, context_pointer inParent)

Derives a child context that carries an immutable typed value.

Creates a new ContextWithValue<T> as a child of the given parent, attaching it to the context tree. If the parent is already cancelled at the time of this call, the child is cancelled immediately with the same error. Otherwise the child is registered with the parent and will be cancelled automatically when the parent is.

Template Parameters
T

Type of the value to carry. Must be move-constructible.

Parameters
inValue

The value to attach to the context.

inParent

The parent context (nullptr by default).

#context_pointer Background() noexcept

Returns the root context of the context tree.

Background is never cancelled, has no deadline, and carries no values. It is intended as the top-level parent for all derived contexts and is the only context that has no parent itself.

The same instance is returned on every call.

#Context::pointer WithCancel(context_pointer inParent=nullptr)

Derives a child context that can be manually cancelled.

The returned context is a child of the given parent. If the parent is already cancelled at the time of this call, the child is cancelled immediately with the same error. Otherwise, the child is registered with the parent and will be cancelled automatically when the parent is.

If no parent is provided, Background() is used as the parent.

Parameters
inParent

The parent context. Defaults to Background() if nullptr.

Returns

A shared_ptr<Context> exposing Cancel() directly.

#std::size_t HardwareConcurrency() noexcept