]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #include "JournalThrottle.h" | |
5 | #include "include/assert.h" | |
6 | ||
7 | bool JournalThrottle::set_params( | |
8 | double _low_threshhold, | |
9 | double _high_threshhold, | |
10 | double _expected_throughput, | |
11 | double _high_multiple, | |
12 | double _max_multiple, | |
13 | uint64_t _throttle_max, | |
14 | std::ostream *errstream) | |
15 | { | |
16 | return throttle.set_params( | |
17 | _low_threshhold, | |
18 | _high_threshhold, | |
19 | _expected_throughput, | |
20 | _high_multiple, | |
21 | _max_multiple, | |
22 | _throttle_max, | |
23 | errstream); | |
24 | } | |
25 | ||
26 | std::chrono::duration<double> JournalThrottle::get(uint64_t c) | |
27 | { | |
28 | return throttle.get(c); | |
29 | } | |
30 | ||
31 | uint64_t JournalThrottle::take(uint64_t c) | |
32 | { | |
33 | return throttle.take(c); | |
34 | } | |
35 | ||
36 | void JournalThrottle::register_throttle_seq(uint64_t seq, uint64_t c) | |
37 | { | |
38 | locker l(lock); | |
39 | journaled_ops.push_back(std::make_pair(seq, c)); | |
40 | } | |
41 | ||
42 | std::pair<uint64_t, uint64_t> JournalThrottle::flush(uint64_t mono_id) | |
43 | { | |
44 | uint64_t to_put_bytes = 0; | |
45 | uint64_t to_put_ops = 0; | |
46 | { | |
47 | locker l(lock); | |
48 | while (!journaled_ops.empty() && | |
49 | journaled_ops.front().first <= mono_id) { | |
50 | to_put_bytes += journaled_ops.front().second; | |
51 | to_put_ops++; | |
52 | journaled_ops.pop_front(); | |
53 | } | |
54 | } | |
55 | throttle.put(to_put_bytes); | |
56 | return make_pair(to_put_ops, to_put_bytes); | |
57 | } | |
58 | ||
59 | uint64_t JournalThrottle::get_current() | |
60 | { | |
61 | return throttle.get_current(); | |
62 | } | |
63 | ||
64 | uint64_t JournalThrottle::get_max() | |
65 | { | |
66 | return throttle.get_max(); | |
67 | } |