Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
wave_executor.hpp
Go to the documentation of this file.
1
11
12
#pragma once
13
#include <cstddef>
14
#include <memory>
15
#include <
toast/export.hpp
>
16
#include <type_traits>
17
#include <vector>
18
19
namespace
toast::_detail
{
20
21
struct
WaveJob
{
22
std::vector<size_t> items;
23
std::vector<size_t> interpreters;
24
};
25
26
class
ItemRunner {
27
public
:
28
template
<
typename
Callable>
29
requires
(!std::is_same_v<std::remove_cvref_t<Callable>, ItemRunner>)
30
ItemRunner(Callable& callable)
noexcept
// NOLINT(google-explicit-constructor)
31
: m_object(
const_cast<
std::remove_const_t<Callable>*
>
(std::addressof(callable))),
32
m_invoke([](
void
*
object
,
size_t
item) { (*
static_cast<
Callable*
>
(object))(item); }) { }
33
34
void
operator()(
size_t
item)
const
{ m_invoke(m_object, item); }
35
36
private
:
37
void
* m_object;
38
void (*m_invoke)(
void
*, size_t);
39
};
40
41
struct
ExecuteOptions
{
42
bool
non_blocking =
true
;
43
const
char
* label =
"Wave worker"
;
44
};
45
50
TOAST_API
void
51
runJobs
(
const
std::vector<WaveJob>& jobs,
size_t
item_count,
ItemRunner
run_item,
const
ExecuteOptions
& options = {});
52
53
}
toast::_detail::ItemRunner
Definition
wave_executor.hpp:26
export.hpp
toast::_detail
Member-robber pattern used by the generated reflection code.
Definition
defer.hpp:16
toast::_detail::runJobs
void runJobs(const std::vector< WaveJob > &jobs, size_t item_count, ItemRunner run_item, const ExecuteOptions &options)
Runs the jobs of a plan in parallel and returns once every item has run.
Definition
wave_executor.cpp:76
toast::_detail::ExecuteOptions
Definition
wave_executor.hpp:41
toast::_detail::WaveJob
Definition
wave_executor.hpp:21
engine
src
toast
world
wave_executor.hpp
Generated by
1.17.0