Xirsys.Sockets.Accumulator.Raw (xturn_sockets v2.2.0)
View SourceNo framing: each push/3 is one immediately poppable packet.
Options
:max_size- maximum queued whole packets (default:1024)
Overflow drops the oldest packet and surfaces :buffer_overflow on the next
pop/1, then draining continues.
Summary
Functions
Builds an empty packet queue.
Dequeues one packet, reports overflow, or returns {:more, acc} when empty.
Enqueues chunk as one packet. Drops the oldest entry when over :max_size.
Functions
Builds an empty packet queue.
Parameters
opts-:max_size(default1024)iex> acc = Xirsys.Sockets.Accumulator.Raw.init([]) iex> acc = Xirsys.Sockets.Accumulator.Raw.push(acc, "hello", %{n: 1}) iex> {:ok, "hello", %{n: 1}, acc} = Xirsys.Sockets.Accumulator.Raw.pop(acc) iex> elem(Xirsys.Sockets.Accumulator.Raw.pop(acc), 0) :more
Dequeues one packet, reports overflow, or returns {:more, acc} when empty.
Parameters
acc- state afterpush/3
Enqueues chunk as one packet. Drops the oldest entry when over :max_size.