common/config_proxy.cc
common/formatter.cc
common/perf_counters_collection.cc
- common/log.cc)
+ common/log.cc
+ common/throttle.cc)
# the specialized version of ceph-common, where
# - the logging is sent to Seastar backend
net/ProtocolV1.cc
net/ProtocolV2.cc
net/chained_dispatchers.cc)
-set(crimson_thread_srcs
- thread/Throttle.cc)
add_library(crimson STATIC
${crimson_auth_srcs}
${crimson_mgr_srcs}
${crimson_mon_srcs}
${crimson_net_srcs}
- ${crimson_thread_srcs}
${CMAKE_SOURCE_DIR}/src/common/buffer_seastar.cc)
target_compile_options(crimson PUBLIC
"-ftemplate-backtrace-limit=0")
--- /dev/null
+#include "throttle.h"
+
+namespace crimson::common {
+
+int64_t Throttle::take(int64_t c)
+{
+ if (!max) {
+ return 0;
+ }
+ count += c;
+ return count;
+}
+
+int64_t Throttle::put(int64_t c)
+{
+ if (!max) {
+ return 0;
+ }
+ if (!c) {
+ return count;
+ }
+ on_free_slots.signal();
+ count -= c;
+ return count;
+}
+
+seastar::future<> Throttle::get(size_t c)
+{
+ if (!max) {
+ return seastar::now();
+ }
+ return on_free_slots.wait([this, c] {
+ return !_should_wait(c);
+ }).then([this, c] {
+ count += c;
+ return seastar::now();
+ });
+}
+
+void Throttle::reset_max(size_t m) {
+ if (max == m) {
+ return;
+ }
+
+ if (m > max) {
+ on_free_slots.signal();
+ }
+ max = m;
+}
+
+bool Throttle::_should_wait(size_t c) const {
+ if (!max) {
+ return false;
+ }
+ return ((c <= max && count + c > max) || // normally stay under max
+ (c >= max && count > max)); // except for large c
+}
+
+} // namespace crimson::common
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*-
+// vim: ts=8 sw=2 smarttab
+
+#pragma once
+
+#include <seastar/core/condition-variable.hh>
+// pull seastar::timer<...>::timer definitions. FIX SEASTAR or reactor.hh
+// is obligatory and should be included everywhere?
+#include <seastar/core/reactor.hh>
+
+#include "common/ThrottleInterface.h"
+
+namespace crimson::common {
+
+class Throttle final : public ThrottleInterface {
+ size_t max = 0;
+ size_t count = 0;
+ // we cannot change the "count" of seastar::semaphore after it is created,
+ // so use condition_variable instead.
+ seastar::condition_variable on_free_slots;
+public:
+ explicit Throttle(size_t m)
+ : max(m)
+ {}
+ int64_t take(int64_t c = 1) override;
+ int64_t put(int64_t c = 1) override;
+ seastar::future<> get(size_t c);
+ size_t get_current() const {
+ return count;
+ }
+ size_t get_max() const {
+ return max;
+ }
+ void reset_max(size_t m);
+private:
+ bool _should_wait(size_t c) const;
+};
+
+} // namespace crimson::common
#include <seastar/core/future.hh>
#include "Fwd.h"
+#include "crimson/common/throttle.h"
#include "crimson/net/chained_dispatchers.h"
-#include "crimson/thread/Throttle.h"
#include "msg/Message.h"
#include "msg/Policy.h"
class Interceptor;
#endif
-using Throttle = crimson::thread::Throttle;
+using Throttle = crimson::common::Throttle;
using SocketPolicy = ceph::net::Policy<Throttle>;
class Messenger {
#include <seastar/core/sharded.hh>
#include "msg/Policy.h"
+#include "crimson/common/throttle.h"
#include "crimson/net/chained_dispatchers.h"
#include "crimson/net/Connection.h"
#include "crimson/net/Socket.h"
-#include "crimson/thread/Throttle.h"
namespace crimson::net {
SocketMessenger& messenger;
std::unique_ptr<Protocol> protocol;
- ceph::net::Policy<crimson::thread::Throttle> policy;
+ ceph::net::Policy<crimson::common::Throttle> policy;
/// the seq num of the last transmitted message
seq_num_t out_seq = 0;
+++ /dev/null
-#include "Throttle.h"
-
-namespace crimson::thread {
-
-int64_t Throttle::take(int64_t c)
-{
- if (!max) {
- return 0;
- }
- count += c;
- return count;
-}
-
-int64_t Throttle::put(int64_t c)
-{
- if (!max) {
- return 0;
- }
- if (!c) {
- return count;
- }
- on_free_slots.signal();
- count -= c;
- return count;
-}
-
-seastar::future<> Throttle::get(size_t c)
-{
- if (!max) {
- return seastar::now();
- }
- return on_free_slots.wait([this, c] {
- return !_should_wait(c);
- }).then([this, c] {
- count += c;
- return seastar::now();
- });
-}
-
-void Throttle::reset_max(size_t m) {
- if (max == m) {
- return;
- }
-
- if (m > max) {
- on_free_slots.signal();
- }
- max = m;
-}
-
-bool Throttle::_should_wait(size_t c) const {
- if (!max) {
- return false;
- }
- return ((c <= max && count + c > max) || // normally stay under max
- (c >= max && count > max)); // except for large c
-}
-
-} // namespace crimson::thread
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*-
-// vim: ts=8 sw=2 smarttab
-
-#pragma once
-
-#include <seastar/core/condition-variable.hh>
-// pull seastar::timer<...>::timer definitions. FIX SEASTAR or reactor.hh
-// is obligatory and should be included everywhere?
-#include <seastar/core/reactor.hh>
-
-#include "common/ThrottleInterface.h"
-
-namespace crimson::thread {
-
-class Throttle final : public ThrottleInterface {
- size_t max = 0;
- size_t count = 0;
- // we cannot change the "count" of seastar::semaphore after it is created,
- // so use condition_variable instead.
- seastar::condition_variable on_free_slots;
-public:
- explicit Throttle(size_t m)
- : max(m)
- {}
- int64_t take(int64_t c = 1) override;
- int64_t put(int64_t c = 1) override;
- seastar::future<> get(size_t c);
- size_t get_current() const {
- return count;
- }
- size_t get_max() const {
- return max;
- }
- void reset_max(size_t m);
-private:
- bool _should_wait(size_t c) const;
-};
-
-} // namespace crimson::thread
#include "messages/MPing.h"
#include "common/ceph_argparse.h"
#include "crimson/auth/DummyAuth.h"
+#include "crimson/common/throttle.h"
#include "crimson/net/Connection.h"
#include "crimson/net/Dispatcher.h"
#include "crimson/net/Messenger.h"
-#include "crimson/thread/Throttle.h"
#include <seastar/core/alien.hh>
#include <seastar/core/app-template.hh>
};
struct Server {
- crimson::thread::Throttle byte_throttler;
+ crimson::common::Throttle byte_throttler;
crimson::net::MessengerRef msgr;
crimson::auth::DummyAuthClientServer dummy_auth;
struct ServerDispatcher : crimson::net::Dispatcher {
};
struct Client {
- crimson::thread::Throttle byte_throttler;
+ crimson::common::Throttle byte_throttler;
crimson::net::MessengerRef msgr;
crimson::auth::DummyAuthClientServer dummy_auth;
struct ClientDispatcher : crimson::net::Dispatcher {