MetaImGUI
1.0.0
ImGui Application Template for C++20
Loading...
Searching...
No Matches
Coroutine.h
Go to the documentation of this file.
1
/*
2
MetaImGUI
3
Copyright (C) 2026 A P Nicholson
4
5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see <https://www.gnu.org/licenses/>.
17
*/
18
19
#pragma once
20
21
#include <coroutine>
22
#include <exception>
23
24
namespace
MetaImGUI
{
25
42
struct
Task
{
43
struct
promise_type
{
44
Task
get_return_object
() noexcept {
45
return
{};
46
}
47
std::suspend_never
initial_suspend
() noexcept {
48
return
{};
49
}
50
std::suspend_never
final_suspend
() noexcept {
51
return
{};
52
}
53
void
return_void
() noexcept {}
54
void
unhandled_exception
() noexcept {
55
// UI-thread coroutines should not throw — terminate so the bug
56
// is loud rather than silently dropping the rest of the flow.
57
std::terminate();
58
}
59
};
60
};
61
62
}
// namespace MetaImGUI
MetaImGUI
Definition
Application.h:30
MetaImGUI::Task::promise_type
Definition
Coroutine.h:43
MetaImGUI::Task::promise_type::final_suspend
std::suspend_never final_suspend() noexcept
Definition
Coroutine.h:50
MetaImGUI::Task::promise_type::get_return_object
Task get_return_object() noexcept
Definition
Coroutine.h:44
MetaImGUI::Task::promise_type::unhandled_exception
void unhandled_exception() noexcept
Definition
Coroutine.h:54
MetaImGUI::Task::promise_type::initial_suspend
std::suspend_never initial_suspend() noexcept
Definition
Coroutine.h:47
MetaImGUI::Task::promise_type::return_void
void return_void() noexcept
Definition
Coroutine.h:53
MetaImGUI::Task
Eager fire-and-forget coroutine return type.
Definition
Coroutine.h:42
include
Coroutine.h
Generated by
1.9.8