data_pool v1.0.1 DataPool.Buffer

Provides a greedy buffer which pulls from upstream to keep it busy until the buffer is full. This can significantly shorten the total time of a stream process by keeping expensive parts of the stream working.

Summary

Functions

Pipe this between streams to buffer between them

Functions

buffer(stream, size, timeout \\ :infinity)

Specs

buffer(Enumerable.t, pos_integer, timeout) :: Stream.t

Pipe this between streams to buffer between them

Example

iex> 1..3
...> |> Stream.map(fn i -> i * 2 end)
...> |> DataPool.Buffer.buffer(1)
...> |> Stream.take(2)
...> |> Enum.to_list
[2,4]