contur2
Loading...
Searching...
No Matches
dispatcher.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <memory>
7
9
10namespace contur {
11
12 class IClock;
13 class IExecutionEngine;
14 class IScheduler;
15 class IVirtualMemory;
16
21 class Dispatcher final : public IDispatcher
22 {
23 public:
25 Dispatcher(IScheduler &scheduler, IExecutionEngine &engine, IVirtualMemory &virtualMemory, IClock &clock);
26 ~Dispatcher() override;
27
28 Dispatcher(const Dispatcher &) = delete;
29 Dispatcher &operator=(const Dispatcher &) = delete;
30 Dispatcher(Dispatcher &&) noexcept;
31 Dispatcher &operator=(Dispatcher &&) noexcept;
32
34 [[nodiscard]] Result<void> createProcess(std::unique_ptr<ProcessImage> process, Tick currentTick) override;
35
37 [[nodiscard]] Result<void> dispatch(std::size_t tickBudget) override;
38
40 [[nodiscard]] Result<void> terminateProcess(ProcessId pid, Tick currentTick) override;
41
43 void tick() override;
44
46 [[nodiscard]] std::size_t processCount() const noexcept override;
47
49 [[nodiscard]] bool hasProcess(ProcessId pid) const noexcept override;
50
51 private:
52 struct Impl;
53 std::unique_ptr<Impl> impl_;
54 };
55
56} // namespace contur
Dispatcher(Dispatcher &&) noexcept
void tick() override
Advances dispatcher clock by one tick.
~Dispatcher() override
std::unique_ptr< Impl > impl_
Definition dispatcher.h:53
bool hasProcess(ProcessId pid) const noexcept override
Checks whether process id is currently managed.
Dispatcher(IScheduler &scheduler, IExecutionEngine &engine, IVirtualMemory &virtualMemory, IClock &clock)
Constructs dispatcher from subsystem references.
Dispatcher & operator=(const Dispatcher &)=delete
Result< void > createProcess(std::unique_ptr< ProcessImage > process, Tick currentTick) override
Admits process and initializes memory/scheduler state.
Result< void > dispatch(std::size_t tickBudget) override
Executes one dispatch cycle for selected process.
std::size_t processCount() const noexcept override
Number of managed processes.
Dispatcher(const Dispatcher &)=delete
Result< void > terminateProcess(ProcessId pid, Tick currentTick) override
Terminates a process and reclaims associated resources.
Abstract clock interface for simulation time.
Definition clock.h:21
Interface for process lifecycle dispatch orchestration.
Abstract execution engine interface.
Scheduler abstraction managing process state queues.
Definition i_scheduler.h:23
Abstract interface for virtual memory management.
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
IDispatcher interface for process lifecycle orchestration.
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