18 : total_size_(total_size)
19 , free_space_(total_size)
22 , buffer_(reinterpret_cast<unsigned char *>(sxmmap(total_size_)))
38 if (size_head < size) {
39 const size_t size_tail = size - size_head;
40 memcpy(
buffer_, reinterpret_cast<const unsigned char *>(data) + size_head,
50 const size_t size_head = std::min(size,
total_size_ - from);
52 memcpy(to,
buffer_ + from, size_head);
54 if (size_head < size) {
55 const size_t size_tail = size - size_head;
56 memcpy(reinterpret_cast<unsigned char *>(to) + size_head,
buffer_,
70 Get(handle,
sizeof(size_tag), &size_tag);
77 size_t size_tag =
size;
78 size +=
sizeof(size_tag);
85 Put(&size_tag,
sizeof(size_tag));
107 Get(
object, size_tag, to);
115 Get(begin, size, to);
ObjectHandle_t PushFront(const void *obj, size_t size)
size_t GetObjectSize(ObjectHandle_t handle) const
void Put(const void *data, size_t size)
ObjectHandle_t RemoveBack()
RingBuffer(size_t total_size)
assert((mem||(size==0))&&"Out Of Memory")
void CopySlice(ObjectHandle_t handle, size_t size, size_t offset, void *to) const
void Get(size_t from, size_t size, void *to) const
static const ObjectHandle_t kInvalidObjectHandle
void CopyObject(ObjectHandle_t handle, void *to) const