]>
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 | ||
4 | #ifndef CEPH_JOURNAL_FUTURE_H | |
5 | #define CEPH_JOURNAL_FUTURE_H | |
6 | ||
7 | #include "include/int_types.h" | |
8 | #include <string> | |
9 | #include <iosfwd> | |
10 | #include <boost/intrusive_ptr.hpp> | |
11fdf7f2 | 11 | #include "include/ceph_assert.h" |
7c673cae FG |
12 | |
13 | class Context; | |
14 | ||
15 | namespace journal { | |
16 | ||
17 | class FutureImpl; | |
18 | ||
19 | class Future { | |
20 | public: | |
21 | typedef boost::intrusive_ptr<FutureImpl> FutureImplPtr; | |
22 | ||
23 | Future() {} | |
24 | Future(const FutureImplPtr &future_impl) : m_future_impl(future_impl) {} | |
25 | ||
26 | inline bool is_valid() const { | |
27 | return m_future_impl.get() != nullptr; | |
28 | } | |
29 | ||
30 | void flush(Context *on_safe); | |
31 | void wait(Context *on_safe); | |
32 | ||
33 | bool is_complete() const; | |
34 | int get_return_value() const; | |
35 | ||
36 | private: | |
37 | friend class Journaler; | |
38 | friend std::ostream& operator<<(std::ostream&, const Future&); | |
39 | ||
40 | inline FutureImplPtr get_future_impl() const { | |
41 | return m_future_impl; | |
42 | } | |
43 | ||
44 | FutureImplPtr m_future_impl; | |
45 | }; | |
46 | ||
47 | void intrusive_ptr_add_ref(FutureImpl *p); | |
48 | void intrusive_ptr_release(FutureImpl *p); | |
49 | ||
50 | std::ostream &operator<<(std::ostream &os, const Future &future); | |
51 | ||
52 | } // namespace journal | |
53 | ||
54 | using journal::intrusive_ptr_add_ref; | |
55 | using journal::intrusive_ptr_release; | |
56 | using journal::operator<<; | |
57 | ||
58 | #endif // CEPH_JOURNAL_FUTURE_H |