Toast Engine
Loading...
Searching...
No Matches
script_dispatch.hpp
Go to the documentation of this file.
1
12
13#pragma once
14
15#include <cstddef>
16#include <functional>
17#include <toast/export.hpp>
18
19namespace scripting {
20
21class TOAST_API ScriptDispatch {
22public:
24 static void enqueue(size_t vm_index, std::move_only_function<void()> job);
25
29 [[nodiscard]]
30 static auto mustQueue(size_t vm_index) noexcept -> bool;
31
33 [[nodiscard]]
34 static auto pending() noexcept -> size_t;
35
42 static auto deliver(int max_rounds = 4) -> size_t;
43
45 static void clear() noexcept;
46};
47
48}
Definition script_dispatch.hpp:21
static auto deliver(int max_rounds=4) -> size_t
Runs the queued work.
Definition script_dispatch.cpp:92
static void clear() noexcept
Drops everything that is still queued without running it; used when the world is torn down.
Definition script_dispatch.cpp:155
static auto pending() noexcept -> size_t
Number of jobs waiting for delivery.
Definition script_dispatch.cpp:88
static auto mustQueue(size_t vm_index) noexcept -> bool
True when a call from this thread into the interpreter vm_index has to join the queue instead of runn...
Definition script_dispatch.cpp:80
static void enqueue(size_t vm_index, std::move_only_function< void()> job)
Queues job which runs while the interpreter vm_index is owned.
Definition script_dispatch.cpp:70