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_stage.hxx
Go to the documentation of this file.
1
3
4
#pragma once
5
#include <
ice/task_queue.hxx
>
6
#include <
ice/task_awaitable.hxx
>
7
#include <
ice/atomic_linked_queue.hxx
>
8
9
namespace
ice
10
{
11
12
template
<
typename
StageObject =
void
>
13
struct
TaskStageAwaitable
14
{
15
inline
explicit
TaskStageAwaitable
(
ice::TaskQueue
&
queue
) noexcept
16
:
_awaitable
{ ._params{.modifier =
TaskAwaitableModifier::Unused
} }
17
,
_queue
{
queue
}
18
{ }
19
20
inline
bool
await_ready
() const noexcept
21
{
22
return
false
;
23
}
24
25
inline
auto
await_suspend
(
ice::coroutine_handle<>
coroutine)
noexcept
26
{
27
_awaitable
._coro = coroutine;
28
_queue
.push_back(&
_awaitable
);
29
}
30
31
inline
auto
await_resume
() const noexcept -> StageObject&
32
{
33
return
*
reinterpret_cast<
StageObject*
>
(
_awaitable
.result.ptr);
34
}
35
36
ice::TaskAwaitableBase
_awaitable
;
37
ice::TaskQueue
&
_queue
;
38
};
39
40
template
<>
41
struct
TaskStageAwaitable
<void>
42
{
43
inline
explicit
TaskStageAwaitable
(
ice::TaskQueue
&
queue
) noexcept
44
:
_awaitable
{ ._params{.modifier =
TaskAwaitableModifier::Unused
} }
45
,
_queue
{
queue
}
46
{ }
47
48
inline
bool
await_ready
() const noexcept
49
{
50
return
false
;
51
}
52
53
inline
auto
await_suspend
(
ice::coroutine_handle<>
coroutine)
noexcept
54
{
55
_awaitable
._coro = coroutine;
56
_queue
.push_back(&
_awaitable
);
57
}
58
59
inline
void
await_resume
() const noexcept
60
{
61
}
62
63
ice::TaskAwaitableBase
_awaitable
;
64
ice::TaskQueue
&
_queue
;
65
};
66
67
template
<
typename
StageResult =
void
>
68
struct
TaskStage
69
{
70
ice::TaskQueue
&
_queue
;
71
72
inline
auto
operator
co_await
()
const
noexcept
->
ice::TaskStageAwaitable<StageResult>
73
{
74
return
ice::TaskStageAwaitable<StageResult>
{
_queue
};
75
}
76
};
77
78
}
// namespace ice
atomic_linked_queue.hxx
ice::TaskQueue
Definition
task_queue.hxx:13
ice::queue
Definition
queue.hxx:111
ice
SPDX-License-Identifier: MIT.
Definition
array.hxx:12
ice::TaskAwaitableModifier::Unused
@ Unused
Definition
task_awaitable.hxx:13
ice::coroutine_handle
std::coroutine_handle< Type > coroutine_handle
Definition
task_types.hxx:42
ice::TaskAwaitableBase
Definition
task_awaitable.hxx:36
ice::TaskStageAwaitable< void >::_queue
ice::TaskQueue & _queue
Definition
task_stage.hxx:64
ice::TaskStageAwaitable< void >::await_suspend
auto await_suspend(ice::coroutine_handle<> coroutine) noexcept
Definition
task_stage.hxx:53
ice::TaskStageAwaitable< void >::_awaitable
ice::TaskAwaitableBase _awaitable
Definition
task_stage.hxx:63
ice::TaskStageAwaitable< void >::TaskStageAwaitable
TaskStageAwaitable(ice::TaskQueue &queue) noexcept
Definition
task_stage.hxx:43
ice::TaskStageAwaitable< void >::await_ready
bool await_ready() const noexcept
Definition
task_stage.hxx:48
ice::TaskStageAwaitable< void >::await_resume
void await_resume() const noexcept
Definition
task_stage.hxx:59
ice::TaskStageAwaitable
Definition
task_stage.hxx:14
ice::TaskStageAwaitable::_awaitable
ice::TaskAwaitableBase _awaitable
Definition
task_stage.hxx:36
ice::TaskStageAwaitable::await_resume
auto await_resume() const noexcept -> StageObject &
Definition
task_stage.hxx:31
ice::TaskStageAwaitable::await_ready
bool await_ready() const noexcept
Definition
task_stage.hxx:20
ice::TaskStageAwaitable::TaskStageAwaitable
TaskStageAwaitable(ice::TaskQueue &queue) noexcept
Definition
task_stage.hxx:15
ice::TaskStageAwaitable::await_suspend
auto await_suspend(ice::coroutine_handle<> coroutine) noexcept
Definition
task_stage.hxx:25
ice::TaskStageAwaitable::_queue
ice::TaskQueue & _queue
Definition
task_stage.hxx:37
ice::TaskStage
Definition
task_stage.hxx:69
ice::TaskStage::_queue
ice::TaskQueue & _queue
Definition
task_stage.hxx:70
task_awaitable.hxx
task_queue.hxx
Generated by
1.18.0