Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::ui::AsyncContext Class Reference

Weak UI invocation context using the existing UiTask awaiters and scheduler. Copies never retain a scene, coroutine closure, node or background executor. Use owning coroutine parameters/captures; only background's separate callable runs outside UI. More...

#include <ui_async.hpp>

Public Member Functions

 AsyncContext ()=default
 Construct an unavailable invocation context.
AsyncTimer until (SchedulerTime deadline) const
AsyncTimer after (std::chrono::milliseconds delay) const noexcept
template<class T>
AsyncReceive< T > receive (std::function< void(AsyncReply< T >)> start) const
template<class Output, class Input, class Work>
requires (std::copy_constructible<Work> && std::is_nothrow_move_constructible_v<Work>)
AsyncReceive< Output > background (std::shared_ptr< const Input > input, Work work) const

Friends

class detail::AsyncInvocation

Detailed Description

Weak UI invocation context using the existing UiTask awaiters and scheduler. Copies never retain a scene, coroutine closure, node or background executor. Use owning coroutine parameters/captures; only background's separate callable runs outside UI.

Member Function Documentation

◆ after()

AsyncTimer portals::ui::AsyncContext::after ( std::chrono::milliseconds delay) const
noexcept
Parameters
delayNonnegative delay in milliseconds, relative to the existing application clock.
Returns
Existing one-shot timer; zero delay still waits for scheduler dispatch. Negative duration or deadline overflow yields INVALID_ARGUMENT; expired context yields CLOSED, foreign use WRONG_THREAD.

◆ background()

template<class Output, class Input, class Work>
requires (std::copy_constructible<Work> && std::is_nothrow_move_constructible_v<Work>)
AsyncReceive< Output > portals::ui::AsyncContext::background ( std::shared_ptr< const Input > input,
Work work ) const
inline
Template Parameters
OutputTransitively immutable result; expected<DomainValue, DomainError> remains domain data.
InputTransitively immutable input with no concurrently mutated aliases.
WorkCopyable, nothrow-movable worker-safe callable under makeBackgroundJob's result contract.
Parameters
inputNon-null owning immutable input; impose application byte limits independently.
workSeparate worker callable; never capture UI refs, this context, frame or invocation closure.
Returns
The existing AsyncReceive, with UI-affine deferred continuation and cooperative cancellation. Full admission retains one latest intent and retries on application cycles without new input. Terminal admission retires that intent and reports ui.async.background once, even if handled. Returning its AsyncError from UiTask separately reports ui.async without a background cause; these are observations at the operation and task boundaries, not distinct underlying failures. Argument construction may throw before entry. No worker is created by this call itself.

◆ receive()

template<class T>
AsyncReceive< T > portals::ui::AsyncContext::receive ( std::function< void(AsyncReply< T >)> start) const
inline
Template Parameters
TTransitively immutable owning result with a worker-safe deleter.
Parameters
startShort UI callback receiving only the existing worker-safe reply endpoint.
Returns
Existing bounded data awaiter; provider must retain rejected publication for retry.

◆ until()

AsyncTimer portals::ui::AsyncContext::until ( SchedulerTime deadline) const
inline
Parameters
deadlineAbsolute monotonic milliseconds in this invocation's scheduler.
Returns
Existing one-shot timer; even due timers resume only through scheduler dispatch.

The documentation for this class was generated from the following file: