contur2
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
15 class MPDispatcher final : public IDispatcher
16 {
17 public:
20 explicit MPDispatcher(std::vector<std::reference_wrapper<IDispatcher>> dispatchers);
21 ~MPDispatcher() override;
22
23 MPDispatcher(const MPDispatcher &) = delete;
26 MPDispatcher &operator=(MPDispatcher &&) noexcept;
27
29 [[nodiscard]] Result<void> createProcess(std::unique_ptr<ProcessImage> process, Tick currentTick) override;
30
32 [[nodiscard]] Result<void> dispatch(std::size_t tickBudget) override;
33
35 [[nodiscard]] Result<void> terminateProcess(ProcessId pid, Tick currentTick) override;
36
38 void tick() override;
39
41 [[nodiscard]] std::size_t processCount() const noexcept override;
42
44 [[nodiscard]] bool hasProcess(ProcessId pid) const noexcept override;
45
46 private:
47 struct Impl;
48 std::unique_ptr<Impl> impl_;
49 };
50
51} // namespace contur
Interface for process lifecycle dispatch orchestration.
~MPDispatcher() override
void tick() override
Ticks all child dispatchers.
MPDispatcher(const MPDispatcher &)=delete
Result< void > createProcess(std::unique_ptr< ProcessImage > process, Tick currentTick) override
Routes a process to one child dispatcher.
MPDispatcher(std::vector< std::reference_wrapper< IDispatcher > > dispatchers)
Constructs MP dispatcher with worker dispatchers.
MPDispatcher(MPDispatcher &&) noexcept
MPDispatcher & operator=(const MPDispatcher &)=delete
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.
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