]>
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 | |
3 | #ifndef CEPH_ASYNC_COMPLETION_H | |
4 | #define CEPH_ASYNC_COMPLETION_H | |
5 | ||
7c673cae FG |
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: | |
11fdf7f2 | 20 | ceph::mutex m_lock = ceph::make_mutex("ContextCompletion::m_lock"); |
7c673cae FG |
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 |