set(libcommon_files
${CMAKE_BINARY_DIR}/src/include/ceph_ver.h
ceph_ver.c
+ common/AsyncOpTracker.cc
common/DecayCounter.cc
common/LogClient.cc
common/LogEntry.cc
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "common/AsyncOpTracker.h"
+#include "include/assert.h"
+#include "include/Context.h"
+
+AsyncOpTracker::AsyncOpTracker()
+ : m_lock("AsyncOpTracker::m_lock", false, false) {
+}
+
+AsyncOpTracker::~AsyncOpTracker() {
+ Mutex::Locker locker(m_lock);
+ assert(m_pending_ops == 0);
+}
+
+void AsyncOpTracker::start_op() {
+ Mutex::Locker locker(m_lock);
+ ++m_pending_ops;
+}
+
+void AsyncOpTracker::finish_op() {
+ Context *on_finish = nullptr;
+ {
+ Mutex::Locker locker(m_lock);
+ assert(m_pending_ops > 0);
+ if (--m_pending_ops == 0) {
+ std::swap(on_finish, m_on_finish);
+ }
+ }
+
+ if (on_finish != nullptr) {
+ on_finish->complete(0);
+ }
+}
+
+void AsyncOpTracker::wait_for_ops(Context *on_finish) {
+ {
+ Mutex::Locker locker(m_lock);
+ assert(m_on_finish == nullptr);
+ if (m_pending_ops > 0) {
+ m_on_finish = on_finish;
+ return;
+ }
+ }
+ on_finish->complete(0);
+}
+
+bool AsyncOpTracker::empty() {
+ Mutex::Locker locker(m_lock);
+ return (m_pending_ops == 0);
+}
+
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_ASYNC_OP_TRACKER_H
+#define CEPH_ASYNC_OP_TRACKER_H
+
+#include "include/int_types.h"
+#include "common/Mutex.h"
+
+struct Context;
+
+class AsyncOpTracker {
+public:
+ AsyncOpTracker();
+ ~AsyncOpTracker();
+
+ void start_op();
+ void finish_op();
+
+ void wait_for_ops(Context *on_finish);
+
+ bool empty();
+
+private:
+ Mutex m_lock;
+ uint32_t m_pending_ops = 0;
+ Context *m_on_finish = nullptr;
+
+};
+
+#endif // CEPH_ASYNC_OP_TRACKER_H
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#include "journal/AsyncOpTracker.h"
-#include "journal/Utils.h"
-#include "include/assert.h"
-
-namespace journal {
-
-AsyncOpTracker::AsyncOpTracker()
- : m_lock(utils::unique_lock_name("AsyncOpTracker::m_lock", this)),
- m_pending_ops(0) {
-}
-
-AsyncOpTracker::~AsyncOpTracker() {
- wait_for_ops();
-}
-
-void AsyncOpTracker::start_op() {
- Mutex::Locker locker(m_lock);
- ++m_pending_ops;
-}
-
-void AsyncOpTracker::finish_op() {
- Context *on_finish = nullptr;
- {
- Mutex::Locker locker(m_lock);
- assert(m_pending_ops > 0);
- if (--m_pending_ops == 0) {
- m_cond.Signal();
- std::swap(on_finish, m_on_finish);
- }
- }
-
- if (on_finish != nullptr) {
- on_finish->complete(0);
- }
-}
-
-void AsyncOpTracker::wait_for_ops() {
- Mutex::Locker locker(m_lock);
- while (m_pending_ops > 0) {
- m_cond.Wait(m_lock);
- }
-}
-
-void AsyncOpTracker::wait_for_ops(Context *on_finish) {
- {
- Mutex::Locker locker(m_lock);
- assert(m_on_finish == nullptr);
- if (m_pending_ops > 0) {
- m_on_finish = on_finish;
- return;
- }
- }
- on_finish->complete(0);
-}
-
-bool AsyncOpTracker::empty() {
- Mutex::Locker locker(m_lock);
- return (m_pending_ops == 0);
-}
-
-} // namespace journal
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#ifndef CEPH_JOURNAL_ASYNC_OP_TRACKER_H
-#define CEPH_JOURNAL_ASYNC_OP_TRACKER_H
-
-#include "include/int_types.h"
-#include "common/Cond.h"
-#include "common/Mutex.h"
-
-struct Context;
-
-namespace journal {
-
-class AsyncOpTracker {
-public:
- AsyncOpTracker();
- ~AsyncOpTracker();
-
- void start_op();
- void finish_op();
-
- void wait_for_ops();
- void wait_for_ops(Context *on_finish);
-
- bool empty();
-
-private:
- Mutex m_lock;
- Cond m_cond;
- uint32_t m_pending_ops;
- Context *m_on_finish = nullptr;
-
-};
-
-} // namespace journal
-
-#endif // CEPH_JOURNAL_ASYNC_OP_TRACKER_H
set(journal_srcs
- AsyncOpTracker.cc
Entry.cc
Future.cc
FutureImpl.cc
#include "include/int_types.h"
#include "include/Context.h"
#include "include/rados/librados.hpp"
+#include "common/AsyncOpTracker.h"
#include "common/Cond.h"
#include "common/Mutex.h"
#include "common/RefCountedObj.h"
#include "common/WorkQueue.h"
#include "cls/journal/cls_journal_types.h"
-#include "journal/AsyncOpTracker.h"
#include "journal/JournalMetadataListener.h"
#include "journal/Settings.h"
#include <boost/intrusive_ptr.hpp>
#include "include/int_types.h"
#include "include/Context.h"
#include "include/rados/librados.hpp"
+#include "common/AsyncOpTracker.h"
#include "common/Mutex.h"
-#include "journal/AsyncOpTracker.h"
#include "journal/JournalMetadata.h"
#include "journal/ObjectPlayer.h"
#include "cls/journal/cls_journal_types.h"
#include "include/int_types.h"
#include "include/rados/librados.hpp"
#include "include/Context.h"
+#include "common/AsyncOpTracker.h"
#include "common/Mutex.h"
-#include "journal/AsyncOpTracker.h"
#include "journal/JournalMetadata.h"
#include "cls/journal/cls_journal_types.h"
#include <functional>