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