LeechCraft
0.6.70-18808-g3467692359
Modular cross-platform feature rich live environment.
Toggle main menu visibility
Loading...
Searching...
No Matches
finalsuspender.h
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#pragma once
10
11
#include <coroutine>
12
#include <mutex>
13
14
namespace
LC::Util::detail
15
{
16
template
<
typename
Promise>
17
struct
FinalSuspender
18
{
19
Promise&
Promise_
;
20
21
bool
await_ready
() const noexcept {
return
false
; }
22
23
std::coroutine_handle<>
await_suspend
(std::coroutine_handle<>)
noexcept
24
{
25
auto
handles = [
this
]
26
{
27
std::lock_guard guard {
Promise_
};
28
return
Promise_
.GetAwaiters ();
29
} ();
30
Promise_
.DecRef ();
31
32
if
constexpr
(std::is_same_v<
decltype
(handles), std::coroutine_handle<>>)
33
return
handles ? handles : std::noop_coroutine ();
34
else
35
{
36
if
(handles.size () == 1)
37
return
handles [0];
38
39
for
(
const
auto
& h : handles)
40
h.resume ();
41
return
std::noop_coroutine ();
42
}
43
}
44
45
void
await_resume
() const noexcept {}
46
};
47
}
LC::Util::detail
Definition
fancytrayiconfreedesktop.cpp:24
LC::Util::detail::FinalSuspender
Definition
finalsuspender.h:18
LC::Util::detail::FinalSuspender::await_resume
void await_resume() const noexcept
Definition
finalsuspender.h:45
LC::Util::detail::FinalSuspender::await_suspend
std::coroutine_handle await_suspend(std::coroutine_handle<>) noexcept
Definition
finalsuspender.h:23
LC::Util::detail::FinalSuspender::Promise_
Promise & Promise_
Definition
finalsuspender.h:19
LC::Util::detail::FinalSuspender::await_ready
bool await_ready() const noexcept
Definition
finalsuspender.h:21
src
util
threads
coro
finalsuspender.h
Generated by
1.17.0