LeechCraft 0.6.70-17335-ge406ffdcaf
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
timer.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 <chrono>
12#include <coroutine>
13#include <QTimer>
14#include "../threadsconfig.h"
15
16namespace LC::Util
17{
18 namespace detail
19 {
21 {
22 QTimer Timer_;
23
24 explicit TimerAwaiter (std::chrono::milliseconds duration, Qt::TimerType precision);
25
26 bool await_ready () const noexcept;
27 void await_suspend (std::coroutine_handle<> handle) noexcept;
28 void await_resume () const noexcept;
29 };
30 }
31
32 template<Qt::TimerType Precision>
34 {
35 std::chrono::milliseconds Duration_;
36
37 auto operator co_await () const
38 {
39 return detail::TimerAwaiter { Duration_, Precision };
40 }
41 };
42
46}
47
48namespace LC
49{
50 UTIL_THREADS_API Util::detail::TimerAwaiter operator co_await (std::chrono::milliseconds duration);
51}
WithPrecision< Qt::PreciseTimer > Precisely
Definition timer.h:43
WithPrecision< Qt::VeryCoarseTimer > VeryCoarsely
Definition timer.h:45
WithPrecision< Qt::CoarseTimer > Coarsely
Definition timer.h:44
Definition constants.h:15
std::chrono::milliseconds Duration_
Definition timer.h:35
bool await_ready() const noexcept
Definition timer.cpp:21
TimerAwaiter(std::chrono::milliseconds duration, Qt::TimerType precision)
Definition timer.cpp:14
void await_resume() const noexcept
Definition timer.cpp:38
void await_suspend(std::coroutine_handle<> handle) noexcept
Definition timer.cpp:26
#define UTIL_THREADS_API