-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathtimer.hpp
46 lines (38 loc) · 1.01 KB
/
timer.hpp
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
/**
* Copyright Quadrivium LLC
* All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#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