View Source EchoPubSub.Producer.RingBuffer (EchoPubSub v0.2.3)
Pure helpers over the producer's fixed-size :array. Cursors only grow; a
cursor maps to slot rem(cursor, capacity), so a write overwrites the message
capacity positions behind it.
Summary
Functions
Number of messages the buffer holds.
An empty buffer holding the last size messages.
What a node with read_cursor still needs: nothing, the messages up to
write_cursor in order, or {:expired, missed} once the oldest missed
were overwritten.
Stores message at cursor, overwriting the slot's previous message.
Types
@type cursor() :: non_neg_integer()
@type pending() :: :caught_up | {:expired, pos_integer()} | {:messages, [term()]}
@type t() :: :array.array()
Functions
@spec capacity(t()) :: pos_integer()
Number of messages the buffer holds.
@spec new(pos_integer()) :: t()
An empty buffer holding the last size messages.
What a node with read_cursor still needs: nothing, the messages up to
write_cursor in order, or {:expired, missed} once the oldest missed
were overwritten.
Stores message at cursor, overwriting the slot's previous message.