class raw_posix_aligned;
class raw_hack_aligned;
class raw_char;
+ class raw_claimed_char;
class raw_pipe;
class raw_unshareable; // diagnostic, unshareable char buffer
class raw_combined;
*/
raw* copy(const char *c, unsigned len);
raw* create(unsigned len);
+ raw* create_in_mempool(unsigned len, int mempool);
raw* claim_char(unsigned len, char *buf);
raw* create_malloc(unsigned len);
raw* claim_malloc(unsigned len, char *buf);
raw* create_static(unsigned len, char *buf);
raw* create_aligned(unsigned len, unsigned align);
+ raw* create_aligned_in_mempool(unsigned len, unsigned align, int mempool);
raw* create_page_aligned(unsigned len);
raw* create_zero_copy(unsigned len, int fd, int64_t *offset);
raw* create_unshareable(unsigned len);
return have_raw() && (start() > 0 || end() < raw_length());
}
+ int get_mempool() const;
+ void reassign_to_mempool(int pool);
+ void try_assign_to_mempool(int pool);
+
// accessors
raw *get_raw() const { return _raw; }
const char *c_str() const;
bool can_zero_copy() const;
int zero_copy_to_fd(int fd, int64_t *offset) const;
- unsigned wasted();
+ unsigned wasted() const;
int cmp(const ptr& o) const;
bool is_zero() const;
void advance(int o);
void seek(unsigned o);
+ using iterator_impl<false>::operator*;
char operator*();
iterator& operator++();
ptr get_current_ptr();
const ptr& front() const { return _buffers.front(); }
const ptr& back() const { return _buffers.back(); }
+ int get_mempool() const;
+ void reassign_to_mempool(int pool);
+ void try_assign_to_mempool(int pool);
+
+ size_t get_append_buffer_unused_tail_length() const {
+ return append_buffer.unused_tail_length();
+ }
+
unsigned get_memcopy_count() const {return _memcopy_count; }
const std::list<ptr>& buffers() const { return _buffers; }
void swap(list& other);
unsigned align_memory);
bool rebuild_page_aligned();
- void reserve(size_t prealloc) {
- if (append_buffer.unused_tail_length() < prealloc) {
- append_buffer = buffer::create(prealloc);
- append_buffer.set_length(0); // unused, so far.
- }
- }
+ void reserve(size_t prealloc);
// assignment-op with move semantics
const static unsigned int CLAIM_DEFAULT = 0;
void claim(list& bl, unsigned int flags = CLAIM_DEFAULT);
void claim_append(list& bl, unsigned int flags = CLAIM_DEFAULT);
void claim_prepend(list& bl, unsigned int flags = CLAIM_DEFAULT);
+ // only for bl is bufferlist::page_aligned_appender
+ void claim_append_piecewise(list& bl);
// clone non-shareable buffers (make shareable)
void make_shareable() {
}
uint32_t crc32c(uint32_t crc) const;
void invalidate_crc();
+
+ // These functions return a bufferlist with a pointer to a single
+ // static buffer. They /must/ not outlive the memory they
+ // reference.
+ static list static_from_mem(char* c, size_t l);
+ static list static_from_cstring(char* c);
+ static list static_from_string(std::string& s);
};
/*
// cppcheck-suppress noExplicitConstructor
hash(uint32_t init) : crc(init) { }
- void update(buffer::list& bl) {
+ void update(const buffer::list& bl) {
crc = bl.crc32c(crc);
}
std::ostream& operator<<(std::ostream& out, const buffer::error& e);
-inline bufferhash& operator<<(bufferhash& l, bufferlist &r) {
+inline bufferhash& operator<<(bufferhash& l, const bufferlist &r) {
l.update(r);
return l;
}