initial code repo
[stor4nfv.git] / src / ceph / src / common / AsyncOpTracker.h
diff --git a/src/ceph/src/common/AsyncOpTracker.h b/src/ceph/src/common/AsyncOpTracker.h
new file mode 100644 (file)
index 0000000..f600cbd
--- /dev/null
@@ -0,0 +1,30 @@
+// -*- 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 "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