LeechCraft  0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
timer.cpp
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 #include "timer.h"
10 #include <QTimer>
11 
12 namespace LC::Util::detail
13 {
14  TimerAwaiter::TimerAwaiter (std::chrono::milliseconds duration, Qt::TimerType precision)
15  {
16  Timer_.setSingleShot (true);
17  Timer_.setInterval (duration);
18  Timer_.setTimerType (precision);
19  }
20 
22  {
23  return false;
24  }
25 
26  void TimerAwaiter::await_suspend (std::coroutine_handle<> handle) noexcept
27  {
28  Timer_.callOnTimeout (handle);
29  Timer_.start ();
30  }
31 
33  {
34  }
35 }
36 
37 namespace LC
38 {
39  Util::detail::TimerAwaiter operator co_await (std::chrono::milliseconds duration)
40  {
41  return Util::detail::TimerAwaiter { duration, Qt::CoarseTimer };
42  }
43 }
bool await_ready() const noexcept
Definition: timer.cpp:21
void await_resume() const noexcept
Definition: timer.cpp:32
void await_suspend(std::coroutine_handle<> handle) noexcept
Definition: timer.cpp:26
auto Tup2 &&tup2 noexcept
Definition: ctstringutils.h:68
TimerAwaiter(std::chrono::milliseconds duration, Qt::TimerType precision)
Definition: timer.cpp:14