]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #pragma once | |
5 | ||
6 | #include <iostream> | |
7 | #include <limits> | |
8 | ||
9 | #include <boost/intrusive_ptr.hpp> | |
10 | #include <boost/smart_ptr/intrusive_ref_counter.hpp> | |
11 | ||
12 | #include "include/buffer.h" | |
13 | #include "include/denc.h" | |
14 | ||
15 | namespace crimson::os::seastore { | |
16 | ||
17 | // in-memory onode, in addition to the stuff that should be persisted to disk, | |
18 | // it may contain intrusive hooks for LRU, rw locks etc | |
19 | class Onode : public boost::intrusive_ref_counter< | |
20 | Onode, | |
21 | boost::thread_unsafe_counter> | |
22 | { | |
23 | public: | |
24 | Onode(std::string_view s) | |
25 | : payload{s} | |
26 | {} | |
27 | size_t size() const; | |
28 | const std::string& get() const { | |
29 | return payload; | |
30 | } | |
31 | void encode(void* buffer, size_t len); | |
32 | DENC(Onode, v, p) { | |
33 | DENC_START(1, 1, p); | |
34 | denc(v.payload, p); | |
35 | DENC_FINISH(p); | |
36 | } | |
37 | ||
38 | private: | |
39 | // dummy payload | |
40 | std::string payload; | |
41 | }; | |
42 | ||
43 | bool operator==(const Onode& lhs, const Onode& rhs); | |
44 | std::ostream& operator<<(std::ostream &out, const Onode &rhs); | |
45 | using OnodeRef = boost::intrusive_ptr<Onode>; | |
46 | } | |
47 | ||
48 | WRITE_CLASS_DENC(crimson::os::seastore::Onode) |