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

Explicit fixed worker owner for a synchronous run or host-owned lifetime. requestStop never joins; join is the explicit final synchronous boundary after UI retirement and terminal close attempt. Destruction also joins as a final safety net, so this type must never be owned by a scene, node, coroutine frame, or host callback. Inputs and cancelled pending jobs can be released on the calling host thread at final retirement; worker-safe deletion does not imply a bounded transitive payload destruction cost. More...

#include <background.hpp>

Inheritance diagram for portals::BackgroundPool:
portals::BackgroundPoolportals::BackgroundPool portals::BackgroundExecutor

Public Member Functions

 BackgroundPool (const BackgroundPool &)=delete
BackgroundPool & operator= (const BackgroundPool &)=delete
std::expected< BackgroundTicket, BackgroundError > submit (std::unique_ptr< BackgroundJob > &job) override
void service () noexcept override
 Permit one publication retry per blocked worker; does not wait or invoke UI callbacks.
std::uint64_t capacityEpoch () const noexcept override
BackgroundWorkerStorage * workerStorage () noexcept override
void requestStop () noexcept
 Close admission, cancel owned jobs and wake workers independently of scheduler progress.
void join () noexcept
 Stop and join owned workers; may wait for cooperative user code, never services UI. Call from the owning synchronous host, never from one of this pool's workers.
Public Member Functions inherited from portals::BackgroundExecutor
virtual ~BackgroundExecutor ()=default
 Concrete owning executors define their final join boundary.

Static Public Member Functions

static std::expected< std::unique_ptr< BackgroundPool >, BackgroundError > create (BackgroundOptions options={}, Publisher< int > wake={})

Detailed Description

Explicit fixed worker owner for a synchronous run or host-owned lifetime. requestStop never joins; join is the explicit final synchronous boundary after UI retirement and terminal close attempt. Destruction also joins as a final safety net, so this type must never be owned by a scene, node, coroutine frame, or host callback. Inputs and cancelled pending jobs can be released on the calling host thread at final retirement; worker-safe deletion does not imply a bounded transitive payload destruction cost.

Member Function Documentation

◆ capacityEpoch()

std::uint64_t portals::BackgroundPool::capacityEpoch ( ) const
overridevirtualnoexcept
Returns
Advisory capacity generation, sampled before submit to avoid a missed release race.

Implements portals::BackgroundExecutor.

◆ create()

std::expected< std::unique_ptr< BackgroundPool >, BackgroundError > portals::BackgroundPool::create ( BackgroundOptions options = {},
Publisher< int > wake = {} )
static
Parameters
optionsPositive worker and pending count bounds.
wakeOptional worker-safe readiness endpoint; only its wake operation is used.
Returns
Fully started owner, or typed allocation/thread startup failure after partial workers stop.

◆ service()

void portals::BackgroundPool::service ( )
overridevirtualnoexcept

Permit one publication retry per blocked worker; does not wait or invoke UI callbacks.

Implements portals::BackgroundExecutor.

◆ submit()

std::expected< BackgroundTicket, BackgroundError > portals::BackgroundPool::submit ( std::unique_ptr< BackgroundJob > & job)
overridevirtual
Parameters
jobOwning worker-safe item; preserved on any rejected admission.
Returns
Cancellation owner on acceptance, or explicit admission failure.

Implements portals::BackgroundExecutor.

◆ workerStorage()

BackgroundWorkerStorage * portals::BackgroundPool::workerStorage ( )
overridevirtualnoexcept
Returns
Optional opaque worker-cache capability, borrowed for this executor's lifetime. Unsupported hosts return nullptr; no synchronous UI-owned cache fallback is permitted.

Reimplemented from portals::BackgroundExecutor.


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