LeechCraft
0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
throttle.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 <QTimer>
12
13
namespace
LC::Util
14
{
15
template
<
typename
F>
16
auto
Throttled
(std::chrono::milliseconds ms, QObject *parent, F&& f)
17
{
18
return
[=, scheduled =
false
, f = std::forward<F> (f)] ()
mutable
19
{
20
if
(scheduled)
21
return
;
22
23
scheduled =
true
;
24
QTimer::singleShot (ms, Qt::VeryCoarseTimer, parent,
25
[&]
26
{
27
std::invoke (f);
28
scheduled =
false
;
29
});
30
};
31
}
32
}
LC::Util
Definition
icoreproxy.h:34
LC::Util::Throttled
auto Throttled(std::chrono::milliseconds ms, QObject *parent, F &&f)
Definition
throttle.h:16
src
util
sll
throttle.h
Generated by
1.13.2