bl.clear();
}
- void buffer::list::claim_append_piecewise(list& bl)
- {
- // steal the other guy's buffers
- for (const auto& node : bl.buffers()) {
- append(node, 0, node.length());
- }
- bl.clear();
- }
-
void buffer::list::append(char c)
{
// put what we can into the existing append_buffer.
void claim_append(list&& bl) {
claim_append(bl);
}
- // only for bl is bufferlist::page_aligned_appender
- void claim_append_piecewise(list& bl);
// copy with explicit volatile-sharing semantics
void share(const list& bl)
EXPECT_EQ((unsigned)0, from.length());
}
-TEST(BufferList, claim_append_piecewise) {
- bufferlist bl, t, dst;
- auto a = bl.get_page_aligned_appender(4);
- for (uint32_t i = 0; i < (CEPH_PAGE_SIZE + CEPH_PAGE_SIZE - 1333); i++)
- a.append("x", 1);
- a.flush();
- const char *p = bl.c_str();
- t.claim_append(bl);
-
- for (uint32_t i = 0; i < (CEPH_PAGE_SIZE + 1333); i++)
- a.append("x", 1);
- a.flush();
- t.claim_append(bl);
-
- EXPECT_FALSE(t.is_aligned_size_and_memory(CEPH_PAGE_SIZE, CEPH_PAGE_SIZE));
- dst.claim_append_piecewise(t);
- EXPECT_TRUE(dst.is_aligned_size_and_memory(CEPH_PAGE_SIZE, CEPH_PAGE_SIZE));
- const char *p1 = dst.c_str();
- EXPECT_TRUE(p == p1);
-}
-
TEST(BufferList, begin) {
bufferlist bl;
bl.append("ABC");