forked from qdrvm/kagome
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.hpp
More file actions
48 lines (39 loc) · 1.08 KB
/
timer.hpp
File metadata and controls
48 lines (39 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef KAGOME_TIMER_HPP
#define KAGOME_TIMER_HPP
#include <functional>
#include <system_error>
#include "clock/clock.hpp"
namespace kagome::clock {
/**
* Interface for asynchronous timer
*/
struct Timer {
virtual ~Timer() = default;
/**
* Set an expire time for this timer
* @param at - timepoint, at which the timer expires
*/
virtual void expiresAt(clock::SystemClock::TimePoint at) = 0;
/**
* Set an expire time for this timer
* @param duration before timer will be expired
*/
virtual void expiresAfter(clock::SystemClock::Duration duration) = 0;
/**
* Cancel timer
*/
virtual void cancel() = 0;
/**
* Wait for the timer expiration
* @param h - handler, which is called, when the timer is expired, or error
* happens
*/
virtual void asyncWait(
const std::function<void(const boost::system::error_code &)> &h) = 0;
};
} // namespace kagome::clock
#endif // KAGOME_TIMER_HPP