]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
31f18b77 FG |
3 | |
4 | #ifndef LIBRBD_IO_ASYNC_OPERATION_H | |
5 | #define LIBRBD_IO_ASYNC_OPERATION_H | |
7c673cae FG |
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 | ||
31f18b77 FG |
17 | namespace io { |
18 | ||
7c673cae FG |
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 | ||
31f18b77 | 49 | } // namespace io |
7c673cae FG |
50 | } // namespace librbd |
51 | ||
31f18b77 | 52 | #endif // LIBRBD_IO_ASYNC_OPERATION_H |