IceShard
1
A personal game engine project, with development focused on 2D/2.5D games.
Toggle main menu visibility
Loading...
Searching...
No Matches
tasks
public
ice
task_checkpoint.hxx
Go to the documentation of this file.
1
3
4
#pragma once
5
#include <
ice/task_types.hxx
>
6
#include <
ice/task_awaitable.hxx
>
7
#include <
ice/task_queue.hxx
>
8
#include <
ice/task_utils.hxx
>
9
#include <
ice/task.hxx
>
10
#include <atomic>
11
12
namespace
ice
13
{
14
15
class
TaskCheckpoint
16
{
17
public
:
18
TaskCheckpoint
(
bool
initially_open =
false
) noexcept;
19
20
bool
is_open
() const noexcept;
21
22
bool
open
() noexcept;
23
bool
open
(
ice
::
TaskScheduler
& scheduler) noexcept;
24
void
close
() noexcept;
25
26
auto
checkpoint_gate
() noexcept ->
ice
::
TaskCheckpointGate
;
27
bool
enqueue_awaitable
(
ice
::
TaskAwaitableBase
& awaitable) noexcept;
28
29
private:
30
std::atomic_int32_t _checkpoint_state;
31
ice
::
TaskQueue
_checkpoint_queue;
32
};
33
34
class
TaskCheckpointGate
35
{
36
public
:
37
TaskCheckpointGate
() noexcept;
38
TaskCheckpointGate
(
ice
::
TaskCheckpoint
& checkpoint) noexcept;
39
40
TaskCheckpointGate
(
ice
::
TaskCheckpointGate
const& other) noexcept;
41
auto operator=(
ice
::
TaskCheckpointGate
const& other) noexcept ->
ice
::
TaskCheckpointGate
&;
42
43
inline
bool
await_ready
() const noexcept;
44
45
inline
bool
await_suspend
(std::
coroutine_handle
<> coro) noexcept;
46
47
inline
void
await_resume
() const noexcept { }
48
49
private
:
50
ice::TaskAwaitableBase
_awaitable;
51
ice::TaskCheckpoint
* _checkpoint;
52
};
53
54
inline
bool
TaskCheckpointGate::await_ready
() const noexcept
55
{
56
return
_checkpoint ==
nullptr
|| _checkpoint->
is_open
();
57
}
58
59
inline
bool
TaskCheckpointGate::await_suspend
(std::coroutine_handle<> coro)
noexcept
60
{
61
_awaitable._coro = coro;
62
return
_checkpoint->enqueue_awaitable(_awaitable);
63
}
64
65
}
// namespace ice
ice::TaskCheckpointGate
Definition
task_checkpoint.hxx:35
ice::TaskCheckpointGate::await_ready
bool await_ready() const noexcept
Definition
task_checkpoint.hxx:54
ice::TaskCheckpointGate::TaskCheckpointGate
TaskCheckpointGate() noexcept
ice::TaskCheckpointGate::await_resume
void await_resume() const noexcept
Definition
task_checkpoint.hxx:47
ice::TaskCheckpointGate::await_suspend
bool await_suspend(std::coroutine_handle<> coro) noexcept
Definition
task_checkpoint.hxx:59
ice::TaskCheckpoint
Definition
task_checkpoint.hxx:16
ice::TaskCheckpoint::enqueue_awaitable
bool enqueue_awaitable(ice::TaskAwaitableBase &awaitable) noexcept
ice::TaskCheckpoint::TaskCheckpoint
TaskCheckpoint(bool initially_open=false) noexcept
ice::TaskCheckpoint::close
void close() noexcept
ice::TaskCheckpoint::is_open
bool is_open() const noexcept
ice::TaskCheckpoint::open
bool open() noexcept
ice::TaskCheckpoint::checkpoint_gate
auto checkpoint_gate() noexcept -> ice::TaskCheckpointGate
ice::TaskQueue
Definition
task_queue.hxx:13
ice::TaskScheduler
Definition
task_scheduler.hxx:13
ice
SPDX-License-Identifier: MIT.
Definition
array.hxx:12
ice::coroutine_handle
std::coroutine_handle< Type > coroutine_handle
Definition
task_types.hxx:42
ice::TaskAwaitableBase
Definition
task_awaitable.hxx:36
task.hxx
task_awaitable.hxx
task_queue.hxx
task_types.hxx
task_utils.hxx
Generated by
1.18.0