Contur 2
Educational OS kernel simulator
Loading...
Searching...
No Matches
mp_dispatcher.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <functional>
7#include <memory>
8#include <vector>
9
11
12namespace contur {
13
14 class IDispatchRuntime;
15
17 class MPDispatcher final : public IDispatcher
18 {
19 public:
23 MPDispatcher(std::vector<std::reference_wrapper<IDispatcher>> dispatchers, IDispatchRuntime &runtime);
24
26 ~MPDispatcher() override;
27
29 MPDispatcher(const MPDispatcher &) = delete;
30
35
37 MPDispatcher &operator=(MPDispatcher &&) noexcept;
38
40 [[nodiscard]] Result<void> createProcess(std::unique_ptr<ProcessImage> process, Tick currentTick) override;
41
43 [[nodiscard]] Result<void> dispatch(std::size_t tickBudget) override;
44
46 [[nodiscard]] Result<void> terminateProcess(ProcessId pid, Tick currentTick) override;
47
49 void tick() override;
50
52 [[nodiscard]] std::size_t processCount() const noexcept override;
53
55 [[nodiscard]] bool hasProcess(ProcessId pid) const noexcept override;
56
57 private:
58 struct Impl;
59 std::unique_ptr<Impl> impl_;
60 };
61
62} // namespace contur
Strategy interface that executes dispatch/tick across dispatcher lanes.
Interface for process lifecycle dispatch orchestration.
~MPDispatcher() override
Destroys MP dispatcher.
void tick() override
Ticks all child dispatchers.
MPDispatcher(const MPDispatcher &)=delete
Copy construction is disabled.
Result< void > createProcess(std::unique_ptr< ProcessImage > process, Tick currentTick) override
Routes a process to one child dispatcher.
MPDispatcher(MPDispatcher &&) noexcept
Move-constructs MP dispatcher state.
MPDispatcher & operator=(const MPDispatcher &)=delete
Copy assignment is disabled.
Result< void > dispatch(std::size_t tickBudget) override
Runs dispatch cycle across all child dispatchers.
std::unique_ptr< Impl > impl_
Result< void > terminateProcess(ProcessId pid, Tick currentTick) override
Terminates process in the child dispatcher that owns it.
std::size_t processCount() const noexcept override
Aggregated number of processes across children.
bool hasProcess(ProcessId pid) const noexcept override
Returns true if any child contains process pid.
MPDispatcher(std::vector< std::reference_wrapper< IDispatcher > > dispatchers, IDispatchRuntime &runtime)
Constructs MP dispatcher with worker dispatchers and required injected runtime strategy.
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