template<LockPolicy lp>
md_config_impl<lp>::md_config_impl(bool is_daemon)
: is_daemon(is_daemon),
- cluster("")
+ cluster(""),
+ lock("md_config_t", true, false)
{
// Load the compile-time list of Option into
// a map so that we can resolve keys quickly.
#include "log/SubsystemMap.h"
#include "common/options.h"
#include "common/subsys_types.h"
-#include "config_fwd.h"
+#include "common/config_fwd.h"
+#include "common/lock_mutex.h"
class CephContext;
extern const char *ceph_conf_level_name(int level);
namespace ceph::internal {
-// empty helper class except when the template argument is policy_mutex
-template<LockPolicy lp>
-class LockMutex {
- struct Locker {};
-public:
- Locker operator()() const {
- return Locker{};
- }
- bool is_locked() const {
- return true;
- }
-};
-
-template<>
-class LockMutex<LockPolicy::MUTEX> {
- mutable Mutex mutex{"md_config_t", true, false};
-public:
- auto operator()() const {
- return Mutex::Locker{mutex};
- }
- bool is_locked() const {
- return mutex.is_locked();
- }
-};
/** This class represents the current Ceph configuration.
*
#pragma once
-namespace ceph::internal {
-
-enum class LockPolicy {
- SINGLE,
- MUTEX,
-};
+#include "lock_policy.h"
+namespace ceph::internal {
template<LockPolicy lp> struct md_config_impl;
template<LockPolicy lp> class md_config_obs_impl;
}
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+
+#pragma once
+
+#include "lock_policy.h"
+#include "Mutex.h"
+
+namespace ceph::internal {
+
+template<LockPolicy lp> class LockCond;
+
+// empty helper class except when the template argument is LockPolicy::MUTEX
+template<LockPolicy lp>
+class LockMutex {
+public:
+ template<typename... Args>
+ LockMutex(Args&& ...) {}
+ auto operator()() const {
+ struct Locker {};
+ return Locker{};
+ }
+ bool is_locked() const {
+ return true;
+ }
+};
+
+template<>
+class LockMutex<LockPolicy::MUTEX> {
+public:
+ template<typename... Args>
+ LockMutex(Args&& ...args)
+ : mutex{std::forward<Args>(args)...}
+ {}
+ auto operator()() const {
+ return Mutex::Locker{mutex};
+ }
+ bool is_locked() const {
+ return mutex.is_locked();
+ }
+private:
+ Mutex& get() {
+ return mutex;
+ }
+ mutable Mutex mutex;
+ friend class LockCond<LockPolicy::MUTEX>;
+};
+
+} // namespace ceph::internal
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+
+#pragma once
+
+namespace ceph::internal {
+
+enum class LockPolicy {
+ SINGLE,
+ MUTEX,
+};
+
+}