FlexibleByteRingQueue

Simple ubyte-based ring queue.

TODO: usage example

Constructors

this
this(size_t dimension)

Constructor. The queue's memory buffer is allocated by the GC.

this
this(IMemManager mem_manager, size_t dimension)

Constructor. Allocates the queue's memory buffer with the provided memory manager.

Members

Classes

ValidationError
class ValidationError

Functions

clear
void clear()

Removes all items from the queue.

load
size_t load(InputStream input)

Restores the queue state and contents, reading from input and expecting data previously written by save() to an output stream.

load
void load(size_t delegate(void[] meta, void[] data) restore)

Restores the queue state and contents.

peek
void[] peek()

Peeks at the item that would be popped next.

pop
void[] pop()

Pops an item from the queue.

push
bool push(void[] item)

Pushes an item into the queue.

push
void[] push(size_t size)

Reserves space for an item of <size> bytes on the queue but doesn't fill the content. The caller is expected to fill in the content using the returned slice.

save
size_t save(OutputStream output)

Writes the queue's state and contents to the given output stream in the following format:

save
void save(void delegate(in void[] meta, in void[] head, in void[] tail = null) store)

Calls the provided delegate, store(), to store the queue state and contents.

used_space
ulong used_space()
willFit
bool willFit(void[] item)

Finds out whether the provided item will fit in the queue. Also considers the need of wrapping.

willFit
bool willFit(size_t bytes)

Finds out whether the provided number of bytes will fit in the queue. Also considers the need of wrapping.

Static functions

pushSize
size_t pushSize(void[] item)

Tells how much space an item would take up when written into the queue. (Including the size of the required item header.)

pushSize
size_t pushSize(size_t bytes)

Tells how much space an item of the specified size would take up when written into the queue. (Including the size of the required item header.)

Structs

ExportMetadata
struct ExportMetadata

Metadata header for saving/loading the queue state

Meta