Blue Brain BioExplorer
Throttle.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015-2018, EPFL/Blue Brain Project
3
*
4
* Responsible Author: Daniel.Nachbaur@epfl.ch
5
*
6
* This file is part of Blue Brain BioExplorer <https://github.com/BlueBrain/BioExplorer>
7
*
8
* This library is free software; you can redistribute it and/or modify it under
9
* the terms of the GNU Lesser General Public License version 3.0 as published
10
* by the Free Software Foundation.
11
*
12
* This library is distributed in the hope that it will be useful, but WITHOUT
13
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15
* details.
16
*
17
* You should have received a copy of the GNU Lesser General Public License
18
* along with this library; if not, write to the Free Software Foundation, Inc.,
19
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
*/
21
22
#pragma once
23
24
#include "
Timeout.h
"
25
26
namespace
core
27
{
33
struct
Throttle
34
{
35
using
Function
= std::function<void()>;
36
void
operator()
(
const
Function
& fn,
const
int64_t wait = 100);
37
void
operator()
(
const
Function
& fn,
const
Function
& later,
38
const
int64_t wait = 100);
39
40
private
:
41
using
time_point =
42
std::chrono::time_point<std::chrono::high_resolution_clock>;
43
time_point _last;
44
bool
_haveLast =
false
;
45
Timeout
_timeout;
46
std::mutex _mutex;
47
};
48
}
// namespace core
Timeout.h
core
Definition:
BaseWindow.cpp:53
core::Throttle
Definition:
Throttle.h:34
core::Throttle::operator()
void operator()(const Function &fn, const int64_t wait=100)
Definition:
Throttle.cpp:39
core::Throttle::Function
std::function< void()> Function
Definition:
Throttle.h:35
core::Timeout
Definition:
Timeout.h:37
platform
plugins
rockets
Throttle.h
Generated by
1.9.1