GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
Schedule.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Ivar Härnqvist
2// SPDX-License-Identifier: MIT
3
4#ifndef GREM_EXECUTION_SCHEDULE_HPP
5#define GREM_EXECUTION_SCHEDULE_HPP
6
8
13
14#include <utility> // std::move
15
16namespace grem::execution {
17
18namespace detail {
19
20[[nodiscard]] GREM_API(execution) String formatScheduleDOTGraph(Span<const Task> tasks, CStringView name);
21
22} // namespace detail
23
34template <typename EntReg, typename ResReg>
35class Schedule {
36public:
41 struct TaskContext {
42 EntReg& entities;
43 ResReg& resources;
44 };
45
51 Schedule() noexcept = default;
52
72 Schedule(ArrayList<Task> tasks, Task::SharedMemorySize requiredSharedMemorySize, String name)
73 : tasks(std::move(tasks))
74 , requiredSharedMemorySize(requiredSharedMemorySize)
75 , name(std::move(name)) {}
76
83 [[nodiscard]] Span<const Task> getTasks() const noexcept {
84 return tasks;
85 }
86
93 [[nodiscard]] Task::SharedMemorySize getRequiredSharedMemorySize() const noexcept {
94 return requiredSharedMemorySize;
95 }
96
103 [[nodiscard]] CStringView getName() const noexcept {
104 return name;
105 }
106
116 [[nodiscard]] String formatDOTGraph() const {
117 return detail::formatScheduleDOTGraph(tasks, name);
118 }
119
120private:
121 ArrayList<Task> tasks{};
122 Task::SharedMemorySize requiredSharedMemorySize = 0;
123 String name{};
124};
125
126} // namespace grem::execution
127
128#endif
Definition ArrayList.hpp:27
Definition Span.hpp:146
Span< const Task > getTasks() const noexcept
Definition Schedule.hpp:83
Schedule() noexcept=default
Construct an empty schedule with an empty name.
CStringView getName() const noexcept
Definition Schedule.hpp:103
Task::SharedMemorySize getRequiredSharedMemorySize() const noexcept
Definition Schedule.hpp:93
Statically scheduled unit of work to be executed by an Executor as part of a task graph.
Definition Task.hpp:30
uint32_t SharedMemorySize
Size, in bytes, of shared memory allocated for a task.
Definition Task.hpp:51
Definition Chunk.hpp:19
constexpr auto move(input_range auto &&range, auto outputIterator)
Definition algorithms.hpp:669
Span(R &&range) -> Span< std::remove_reference_t< decltype(*std::data(range))> >
StringBase< char, std::char_traits< char >, std::allocator< char > > String
Definition String.hpp:17
CStringViewBase< char, std::char_traits< char > > CStringView
Definition CStringView.hpp:635
Task context that the scheduled tasks expect to receive a pointer to through their void* context para...
Definition Schedule.hpp:41
EntReg & entities
Reference to the entity registry provided to the scheduled tasks.
Definition Schedule.hpp:42
ResReg & resources
Reference to the resource registry provided to the scheduled tasks.
Definition Schedule.hpp:43