Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / librbd / io / AsyncOperation.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef LIBRBD_IO_ASYNC_OPERATION_H
5 #define LIBRBD_IO_ASYNC_OPERATION_H
6
7 #include "include/assert.h"
8 #include "include/xlist.h"
9 #include <list>
10
11 class Context;
12
13 namespace librbd {
14
15 class ImageCtx;
16
17 namespace io {
18
19 class AsyncOperation {
20 public:
21
22   AsyncOperation()
23     : m_image_ctx(NULL), m_xlist_item(this)
24   {
25   }
26
27   ~AsyncOperation()
28   {
29     assert(!m_xlist_item.is_on_list());
30   }
31
32   inline bool started() const {
33     return m_xlist_item.is_on_list();
34   }
35
36   void start_op(ImageCtx &image_ctx);
37   void finish_op();
38
39   void add_flush_context(Context *on_finish);
40
41 private:
42
43   ImageCtx *m_image_ctx;
44   xlist<AsyncOperation *>::item m_xlist_item;
45   std::list<Context *> m_flush_contexts;
46
47 };
48
49 } // namespace io
50 } // namespace librbd
51
52 #endif // LIBRBD_IO_ASYNC_OPERATION_H