Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / common / ContextCompletion.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 #ifndef CEPH_ASYNC_COMPLETION_H
4 #define CEPH_ASYNC_COMPLETION_H
5
6 #include "include/Context.h"
7
8 namespace ceph {
9
10 class ContextCompletion {
11 public:
12   ContextCompletion(Context *ctx, bool ignore_enoent);
13
14   void finish_adding_requests();
15
16   void start_op();
17   void finish_op(int r);
18
19 private:
20   Mutex m_lock;
21   Context *m_ctx;
22   bool m_ignore_enoent;
23   int m_ret;
24   bool m_building;
25   uint64_t m_current_ops;
26 };
27
28 class C_ContextCompletion : public Context {
29 public:
30   C_ContextCompletion(ContextCompletion &context_completion)
31     : m_context_completion(context_completion)
32   {
33     m_context_completion.start_op();
34   }
35
36   void finish(int r) override {
37     m_context_completion.finish_op(r);
38   }
39
40 private:
41   ContextCompletion &m_context_completion;
42 };
43
44 } // namespace ceph
45
46 #endif // CEPH_ASYNC_COMPLETION_H