ProducerQueue.PriorityKeyServer (producer_queue v5.0.2) View Source

Implementation details:

iex> alias ProducerQueue.PriorityKeyServer
...> priority_keys = [:h, :l, :empty]
...> high = {3, :queue.from_list([1, 2, 3])}
...> low = {4, :queue.from_list(~w(d e f g)a)}
...> empty = {0, {[], []}}
...> state = {priority_keys, %{h: high, l: low, empty: empty}}
...> {_, [1], state} = PriorityKeyServer.handle_call({:pop, 1}, :_, state)
...> {_, [2, 3], state} = PriorityKeyServer.handle_call({:pop, 2}, :_, state)
...> {_, _, state} = PriorityKeyServer.handle_call({:push, {:h, [4]}}, :_, state)
...> {_, [4], _state} = PriorityKeyServer.handle_call({:pop, 1}, :_, state)

iex> alias ProducerQueue.PriorityKeyServer
...> priority_keys = [:h, :l, :empty]
...> high = {3, :queue.from_list([1, 2, 3])}
...> low = {4, :queue.from_list(~w(d e f g)a)}
...> empty = {0, {[], []}}
...> state = {priority_keys, %{h: high, l: low, empty: empty}}
...> {_, [], state} = PriorityKeyServer.handle_call({:pop, 0}, :_, state)
...> {_, [1, 2, 3, :d, :e, :f, :g], _} = PriorityKeyServer.handle_call({:pop, 10}, :_, state)

iex> alias ProducerQueue.PriorityKeyServer
...> priority_keys = [:h, :l]
...> empty = {0, {[], []}}
...> state = {priority_keys, %{h: empty, l: empty}}
...> {:noreply, state} = PriorityKeyServer.handle_cast({:push, {:_, [:a]}}, state)
...> {_, [:a], _} = PriorityKeyServer.handle_call({:pop, 1}, :_, state)

iex> alias ProducerQueue.PriorityKeyServer
...> {_, {[:a, :b, :c], _}} = PriorityKeyServer.init(priority: [:a, :b, :c])

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Callback implementation for GenServer.init/1.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Callback implementation for GenServer.init/1.