1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*-
2 // vim: ts=8 sw=2 smarttab
6 #include <seastar/core/condition-variable.hh>
7 // pull seastar::timer<...>::timer definitions. FIX SEASTAR or reactor.hh
8 // is obligatory and should be included everywhere?
9 #include <seastar/core/reactor.hh>
11 #include "common/ThrottleInterface.h"
13 namespace crimson::common
{
15 class Throttle final
: public ThrottleInterface
{
19 // we cannot change the "count" of seastar::semaphore after it is created,
20 // so use condition_variable instead.
21 seastar::condition_variable on_free_slots
;
23 explicit Throttle(size_t m
)
26 int64_t take(int64_t c
= 1) override
;
27 int64_t put(int64_t c
= 1) override
;
28 seastar::future
<> get(size_t c
);
29 size_t get_current() const {
32 size_t get_max() const {
35 size_t get_pending() const {
38 void reset_max(size_t m
);
40 bool _should_wait(size_t c
) const;
43 } // namespace crimson::common