contur2
Loading...
Searching...
No Matches
i_dispatcher.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <cstddef>
7#include <memory>
8
9#include "contur/core/error.h"
10#include "contur/core/types.h"
11
12namespace contur {
13
14 class ProcessImage;
15
18 {
19 public:
20 virtual ~IDispatcher() = default;
21
26 [[nodiscard]] virtual Result<void> createProcess(std::unique_ptr<ProcessImage> process, Tick currentTick) = 0;
27
31 [[nodiscard]] virtual Result<void> dispatch(std::size_t tickBudget) = 0;
32
37 [[nodiscard]] virtual Result<void> terminateProcess(ProcessId pid, Tick currentTick) = 0;
38
40 virtual void tick() = 0;
41
43 [[nodiscard]] virtual std::size_t processCount() const noexcept = 0;
44
46 [[nodiscard]] virtual bool hasProcess(ProcessId pid) const noexcept = 0;
47 };
48
49} // namespace contur
Interface for process lifecycle dispatch orchestration.
virtual std::size_t processCount() const noexcept=0
Returns number of processes tracked by dispatcher.
virtual Result< void > createProcess(std::unique_ptr< ProcessImage > process, Tick currentTick)=0
Admits a new process into the system.
virtual Result< void > dispatch(std::size_t tickBudget)=0
Runs one scheduling/execution dispatch cycle.
virtual ~IDispatcher()=default
virtual Result< void > terminateProcess(ProcessId pid, Tick currentTick)=0
Terminates a managed process immediately.
virtual bool hasProcess(ProcessId pid) const noexcept=0
Returns whether process exists.
virtual void tick()=0
Advances dispatcher-owned simulation time by one tick.
Full in-memory representation of a process.
A result type that holds either a success value of type T or an ErrorCode.
Definition error.h:104
Error codes and Result<T> type for fallible operations.
Definition block.h:15
std::uint64_t Tick
Simulation clock tick counter.
Definition types.h:18
std::uint32_t ProcessId
Unique identifier for a process.
Definition types.h:12
Common type aliases, sentinel constants, and forward declarations used throughout the Contur 2 kernel...