#include <FifoBuffer.h>
Definition at line 17 of file FifoBuffer.h.
◆ FifoBuffer()
FifoBuffer::FifoBuffer |
( |
int |
pageSize | ) |
|
|
explicit |
◆ GetAvailable()
int64_t FifoBuffer::GetAvailable |
( |
| ) |
const |
◆ Read()
int64_t FifoBuffer::Read |
( |
void * |
data, |
|
|
int64_t |
size |
|
) |
| |
Definition at line 68 of file FifoBuffer.cpp.
69{
71
72 int8_t* dataPtr = static_cast<int8_t*>(data);
73
74 int bytesRead = 0;
75
77 {
79 auto toRead =
81
83 page->Data.begin() + page->ReadPosition,
84 page->Data.begin() + page->ReadPosition + toRead, dataPtr);
85 page->ReadPosition += toRead;
87
88 dataPtr += toRead;
90 bytesRead += toRead;
91
93 {
94 page->Reset();
97 }
98 }
99
100 return bytesRead;
101}
std::deque< Page * > mFreePages
std::queue< Page * > mActivePages
void copy(const T *src, T *dst, int32_t n)
References staffpad::vo::copy(), mActivePages, mAvaliable, mFreePages, min(), mPageSize, and size.
◆ Write()
int64_t FifoBuffer::Write |
( |
const void * |
data, |
|
|
int64_t |
size |
|
) |
| |
Definition at line 31 of file FifoBuffer.cpp.
32{
33 const int8_t* data = static_cast<const int8_t*>(dataPtr);
34
35 auto bytesLeft =
size;
36
37 while (bytesLeft > 0)
38 {
39 if (
42 {
44 {
47 }
48
51 }
52
55 bytesLeft,
static_cast<int64_t
>(
mPageSize - page->WritePosition));
56
57 std::copy(data, data + toWrite, page->Data.begin() + page->WritePosition);
58 page->WritePosition += toWrite;
60
61 data += toWrite;
62 bytesLeft -= toWrite;
63 }
64
66}
std::deque< Page > mAllocatedPages
References staffpad::vo::copy(), mActivePages, mAllocatedPages, mAvaliable, mFreePages, min(), mPageSize, and size.
◆ mActivePages
std::queue<Page*> FifoBuffer::mActivePages |
|
private |
◆ mAllocatedPages
std::deque<Page> FifoBuffer::mAllocatedPages |
|
private |
◆ mAvaliable
int64_t FifoBuffer::mAvaliable {} |
|
private |
◆ mFreePages
std::deque<Page*> FifoBuffer::mFreePages |
|
private |
◆ mPageSize
const int FifoBuffer::mPageSize {} |
|
private |
The documentation for this class was generated from the following files: