Xirsys.Sockets.Accumulator.Reorder (xturn_sockets v2.2.0)
View SourceReordering decorator over any inner Accumulator.
Whole packets from the inner accumulator are tagged with an integer key via
key_fun.(packet, meta). Keys must be contiguous for in-order release,
starting at the first key observed. Packets tagged :unordered skip the
reorder buffer.
Options
:inner- inner accumulator module (default:Accumulator.Raw):inner_opts- options passed toinner.init/1:key_fun- required(packet, meta) -> integer() | :unordered:name- config lookup key forConfig.reorder_opts/2:window,:max_delay_ms,:on_overflow,:enabled- tunables via config and/or explicit opts (Config.reorder_opts/2):clock- injectable clock, defaults toSystem.monotonic_time/1:max_size- bound on the ready queue (default:1024)
Summary
Functions
Builds reorder state. Raises if :key_fun is missing.
Releases the next in-order packet, or {:more, acc} while a gap remains.
Pushes chunk into the inner accumulator.
Functions
Builds reorder state. Raises if :key_fun is missing.
Parameters
opts- see module optionsiex> keyfun = fn <<n, ::binary>>, -> n end iex> acc = Xirsys.Sockets.Accumulator.Reorder.init(key_fun: key_fun) iex> acc = ...> acc ...> |> Xirsys.Sockets.Accumulator.Reorder.push(<<2>>, %{}) ...> |> Xirsys.Sockets.Accumulator.Reorder.push(<<1>>, %{}) iex> {:ok, <<1>>, , acc} = Xirsys.Sockets.Accumulator.Reorder.pop(acc) iex> {:ok, <<2>>, _, acc} = Xirsys.Sockets.Accumulator.Reorder.pop(acc) iex> elem(Xirsys.Sockets.Accumulator.Reorder.pop(acc), 0) :more
Releases the next in-order packet, or {:more, acc} while a gap remains.
Parameters
acc- state afterpush/3
Pushes chunk into the inner accumulator.