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
24namespace MetaImGUI {
25
42struct Task {
43 struct promise_type {
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
std::suspend_never final_suspend() noexcept
Definition Coroutine.h:50
Task get_return_object() noexcept
Definition Coroutine.h:44
void unhandled_exception() noexcept
Definition Coroutine.h:54
std::suspend_never initial_suspend() noexcept
Definition Coroutine.h:47
void return_void() noexcept
Definition Coroutine.h:53
Eager fire-and-forget coroutine return type.
Definition Coroutine.h:42