Blue Brain BioExplorer
Timeout.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 <condition_variable>
25 #include <functional>
26 #include <future>
27 #include <mutex>
28 
29 namespace core
30 {
36 struct Timeout
37 {
38  ~Timeout();
39  void set(const std::function<void()>& func, const int64_t wait);
40  void clear();
41 
42 private:
43  std::mutex _mutex;
44  std::condition_variable _condition;
45  std::future<void> _timeout;
46  std::atomic_bool _cleared{true};
47 };
48 } // namespace core
void clear()
Definition: Timeout.cpp:55
void set(const std::function< void()> &func, const int64_t wait)
Definition: Timeout.cpp:31