Contur 2
Educational OS kernel simulator
Loading...
Searching...
No Matches
contur::DispatcherPool Class Referencefinal

Host-thread worker pool runtime for dispatcher lanes. More...

#include <dispatcher_pool.h>

Inheritance diagram for contur::DispatcherPool:

Public Member Functions

 DispatcherPool (HostThreadingConfig config={})
 Constructs a worker pool runtime.
 ~DispatcherPool () override
 Destroys pool runtime and joins worker threads.
 DispatcherPool (const DispatcherPool &)=delete
 Copy construction is disabled.
DispatcherPooloperator= (const DispatcherPool &)=delete
 Copy assignment is disabled.
 DispatcherPool (DispatcherPool &&) noexcept
 Move-constructs pool runtime state.
DispatcherPooloperator= (DispatcherPool &&) noexcept
 Move-assigns pool runtime state.
std::string_view name () const noexcept override
 Returns runtime implementation name.
const HostThreadingConfigconfig () const noexcept override
 Returns runtime-owned normalized threading config.
Result< void > dispatch (const DispatcherLanes &lanes, std::size_t tickBudget) override
 Runs one pooled dispatch pass across all lanes.
void tick (const DispatcherLanes &lanes) override
 Ticks lanes using pooled workers.
std::uint64_t lastEpoch () const noexcept
 Last completed runtime epoch identifier.
std::vector< std::size_t > lastDeterministicOrder () const
 Stable lane order used by deterministic dispatch mode.
std::vector< TraceEventlastTraceEvents () const
 Runtime trace metadata emitted by the last dispatch/tick pass.
Public Member Functions inherited from contur::IDispatchRuntime
virtual ~IDispatchRuntime ()=default

Private Attributes

std::unique_ptr< Impl > impl_

Detailed Description

Host-thread worker pool runtime for dispatcher lanes.

DispatcherPool owns worker threads and executes lane dispatch/tick jobs using runtime-owned HostThreadingConfig. Deterministic mode uses stable static lane partitioning; non-deterministic mode can use dynamic work stealing when enabled.

Two-level work stealing

Work stealing operates at two independent, non-conflicting levels:

  1. Runtime-level stealing (this class): when workStealing is enabled in the HostThreadingConfig, an idle worker thread may pick up a lane that was originally assigned to another worker. This rebalances dispatcher lanes across host threads.
  2. Scheduler-level stealing (Scheduler / IScheduler::stealNextForLane): within a single dispatcher lane, the scheduler may pull the oldest-ready process from a neighbouring per-core ready queue. This rebalances simulated processes across lanes inside one dispatcher.

The two levels are orthogonal: runtime stealing moves whole lanes between threads, scheduler stealing moves processes between ready queues. Enabling one does not affect the other.

Definition at line 38 of file dispatcher_pool.h.

Constructor & Destructor Documentation

◆ DispatcherPool() [1/3]

contur::DispatcherPool::DispatcherPool ( HostThreadingConfig config = {})
explicit

Constructs a worker pool runtime.

Parameters
configRuntime threading config owned and normalized by the runtime.

References config().

Referenced by DispatcherPool(), DispatcherPool(), operator=(), and operator=().

◆ ~DispatcherPool()

contur::DispatcherPool::~DispatcherPool ( )
override

Destroys pool runtime and joins worker threads.

◆ DispatcherPool() [2/3]

contur::DispatcherPool::DispatcherPool ( const DispatcherPool & )
delete

Copy construction is disabled.

References DispatcherPool().

◆ DispatcherPool() [3/3]

contur::DispatcherPool::DispatcherPool ( DispatcherPool && )
noexcept

Move-constructs pool runtime state.

References DispatcherPool().

Member Function Documentation

◆ config()

const HostThreadingConfig & contur::DispatcherPool::config ( ) const
nodiscardoverridevirtualnoexcept

Returns runtime-owned normalized threading config.

Implements contur::IDispatchRuntime.

References config().

Referenced by config(), and DispatcherPool().

◆ dispatch()

Result< void > contur::DispatcherPool::dispatch ( const DispatcherLanes & lanes,
std::size_t tickBudget )
nodiscardoverridevirtual

Runs one pooled dispatch pass across all lanes.

Implements contur::IDispatchRuntime.

References dispatch().

Referenced by dispatch().

◆ lastDeterministicOrder()

std::vector< std::size_t > contur::DispatcherPool::lastDeterministicOrder ( ) const
nodiscard

Stable lane order used by deterministic dispatch mode.

References lastDeterministicOrder().

Referenced by lastDeterministicOrder().

◆ lastEpoch()

std::uint64_t contur::DispatcherPool::lastEpoch ( ) const
nodiscardnoexcept

Last completed runtime epoch identifier.

References lastEpoch().

Referenced by lastEpoch().

◆ lastTraceEvents()

std::vector< TraceEvent > contur::DispatcherPool::lastTraceEvents ( ) const
nodiscard

Runtime trace metadata emitted by the last dispatch/tick pass.

References lastTraceEvents().

Referenced by lastTraceEvents().

◆ name()

std::string_view contur::DispatcherPool::name ( ) const
nodiscardoverridevirtualnoexcept

Returns runtime implementation name.

Implements contur::IDispatchRuntime.

References name().

Referenced by name().

◆ operator=() [1/2]

DispatcherPool & contur::DispatcherPool::operator= ( const DispatcherPool & )
delete

Copy assignment is disabled.

References DispatcherPool().

◆ operator=() [2/2]

DispatcherPool & contur::DispatcherPool::operator= ( DispatcherPool && )
noexcept

Move-assigns pool runtime state.

References DispatcherPool().

◆ tick()

void contur::DispatcherPool::tick ( const DispatcherLanes & lanes)
overridevirtual

Ticks lanes using pooled workers.

Implements contur::IDispatchRuntime.

References tick().

Referenced by tick().

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> contur::DispatcherPool::impl_
private

Definition at line 82 of file dispatcher_pool.h.


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