HikoGUI
Select Version:
main (latest dev)
0.8.1 (latest)
0.8.0
0.7.0
0.6.0
0.5.1
0.5.0
0.4.0
0.3.0
0.2.3
0.2.2
0.2.1
0.2.0
0.1.0
theme-value
theme-tag
text
ranged-int
phrase-mask-chars
new-window-widget
msvs-bug-20230517
msvs-bug-20230503
msvs-bug-20230428
msvc-c1001-20231106
msvc-bug-20230706
msvc-bug-20221214
modules-part1
label-delegate
bug-msvs-20220928
attribute-parser
⚠️ This documents the
main
development branch of HikoGUI. It might differ from release versions.
A low latency retained GUI
Toggle main menu visibility
Main Page
Related Pages
Topics
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
Variables
c
d
g
i
l
o
p
r
s
t
x
Typedefs
Enumerations
a
b
c
d
f
g
h
k
l
p
s
t
u
v
w
Concepts
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
Related Symbols
a
b
c
d
e
f
g
h
i
m
n
o
p
r
s
t
Files
File List
Globals
All
Functions
Macros
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Concepts
Loading...
Searching...
No Matches
src
hikogui
dispatch
awaitable_timer_intf.hpp
1
// Copyright Take Vos 2022.
2
// Distributed under the Boost Software License, Version 1.0.
3
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5
#pragma once
6
7
#include "awaitable.hpp"
8
#include "../concurrency/concurrency.hpp"
9
#include "../time/time.hpp"
10
#include "../macros.hpp"
11
#include <chrono>
12
#include <coroutine>
13
#include <functional>
14
15
hi_export_module(hikogui.dispatch : awaitable_timer_intf);
16
17
hi_export
namespace
hi::inline
v1
{
18
19
class
awaitable_timer
{
20
public
:
21
awaitable_timer
(
awaitable_timer
&&)
noexcept
=
default
;
22
awaitable_timer
&operator=(
awaitable_timer
&&)
noexcept
=
default
;
23
24
awaitable_timer
(
awaitable_timer
const
&other) noexcept : _deadline(other._deadline) {}
25
26
awaitable_timer
&operator=(
awaitable_timer
const
&other)
noexcept
27
{
28
_callback =
nullptr
;
29
_deadline = other._deadline;
30
return
*
this
;
31
}
32
33
template
<
typename
Duration>
34
awaitable_timer
(
std::chrono::time_point<std::chrono::utc_clock, Duration>
deadline) noexcept : _deadline(deadline)
35
{
36
}
37
38
template
<
typename
Rep,
typename
Period>
39
awaitable_timer
(
std::chrono::duration<Rep, Period>
period) noexcept :
awaitable_timer
(std::chrono::utc_clock::now() + period)
40
{
41
}
42
43
[[nodiscard]]
bool
await_ready()
const
noexcept
44
{
45
return
std::chrono::utc_clock::now() > _deadline;
46
}
47
48
void
await_suspend(std::coroutine_handle<> handle)
noexcept
;
49
50
void
await_resume()
const
noexcept
{}
51
52
private
:
53
utc_nanoseconds _deadline;
54
callback<void()> _callback;
55
};
19
class
awaitable_timer
{
…
};
56
57
template
<
typename
Rep,
typename
Period>
58
struct
awaitable_cast
<
std
::chrono::duration<Rep, Period>> {
59
awaitable_timer
operator()(
std::chrono::duration<Rep, Period>
const
& rhs)
const
noexcept
60
{
61
return
awaitable_timer
{rhs};
62
}
63
};
58
struct
awaitable_cast
<
std
::chrono::duration<Rep, Period>> {
…
};
64
65
template
<
typename
Duration>
66
struct
awaitable_cast
<
std
::chrono::time_point<std::chrono::utc_clock, Duration>> {
67
awaitable_timer
operator()(
std::chrono::time_point<std::chrono::utc_clock, Duration>
const
& rhs)
noexcept
68
{
69
return
awaitable_timer
{rhs};
70
}
71
};
66
struct
awaitable_cast
<
std
::chrono::time_point<std::chrono::utc_clock, Duration>> {
…
};
72
73
}
// namespace hi::inline v1
std
STL namespace.
v1
DOXYGEN BUG.
Definition
algorithm_misc.hpp:20
v1::awaitable_cast
Definition
awaitable.hpp:41
v1::awaitable_timer
Definition
awaitable_timer_intf.hpp:19
std::chrono::duration
std::chrono::time_point
Generated on Mon Apr 22 2024 12:51:34 for HikoGUI by
1.10.0