contur2
Loading...
Searching...
No Matches
scheduler.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <memory>
7
9
10namespace contur {
11
16 class Scheduler final : public IScheduler
17 {
18 public:
21 explicit Scheduler(std::unique_ptr<ISchedulingPolicy> policy);
22 ~Scheduler() override;
23
24 Scheduler(const Scheduler &) = delete;
25 Scheduler &operator=(const Scheduler &) = delete;
26 Scheduler(Scheduler &&) noexcept;
27 Scheduler &operator=(Scheduler &&) noexcept;
28
30 [[nodiscard]] Result<void> enqueue(PCB &pcb, Tick currentTick) override;
31
33 [[nodiscard]] Result<void> dequeue(ProcessId pid) override;
34
36 [[nodiscard]] Result<ProcessId> selectNext(const IClock &clock) override;
37
39 [[nodiscard]] Result<void> blockRunning(Tick currentTick) override;
40
42 [[nodiscard]] Result<void> unblock(ProcessId pid, Tick currentTick) override;
43
45 [[nodiscard]] Result<void> terminate(ProcessId pid, Tick currentTick) override;
46
48 [[nodiscard]] std::vector<ProcessId> getQueueSnapshot() const override;
49
51 [[nodiscard]] std::vector<ProcessId> getBlockedSnapshot() const override;
52
54 [[nodiscard]] ProcessId runningProcess() const noexcept override;
55
57 [[nodiscard]] Result<void> setPolicy(std::unique_ptr<ISchedulingPolicy> policy) override;
58
60 [[nodiscard]] std::string_view policyName() const noexcept;
61
62 private:
63 struct Impl;
64 std::unique_ptr<Impl> impl_;
65 };
66
67} // namespace contur
Abstract clock interface for simulation time.
Definition clock.h:21
Scheduler abstraction managing process state queues.
Definition i_scheduler.h:23
Strategy interface for scheduling algorithms.
Process Control Block — stores all metadata for a single process.
Definition pcb.h:55
A result type that holds either a success value of type T or an ErrorCode.
Definition error.h:104
Scheduler & operator=(const Scheduler &)=delete
std::vector< ProcessId > getBlockedSnapshot() const override
Snapshot of blocked queue process IDs.
Result< void > blockRunning(Tick currentTick) override
Moves running process to blocked state.
Scheduler(Scheduler &&) noexcept
Scheduler(const Scheduler &)=delete
Result< void > dequeue(ProcessId pid) override
Removes process from scheduler tracking.
Result< ProcessId > selectNext(const IClock &clock) override
Selects next process according to active policy.
std::unique_ptr< Impl > impl_
Definition scheduler.h:64
std::vector< ProcessId > getQueueSnapshot() const override
Snapshot of ready queue process IDs.
Scheduler(std::unique_ptr< ISchedulingPolicy > policy)
Constructs scheduler with initial policy.
~Scheduler() override
std::string_view policyName() const noexcept
Returns active policy name.
Result< void > terminate(ProcessId pid, Tick currentTick) override
Terminates process and removes it from scheduler state.
ProcessId runningProcess() const noexcept override
Currently running process ID or INVALID_PID.
Result< void > setPolicy(std::unique_ptr< ISchedulingPolicy > policy) override
Replaces the active scheduling policy.
Result< void > unblock(ProcessId pid, Tick currentTick) override
Moves blocked process back to ready queue.
Result< void > enqueue(PCB &pcb, Tick currentTick) override
Enqueues process into ready queue.
IScheduler interface.
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