Packages

AgentMap can be seen as a stateful Map that parallelize operations made on different keys. Basically, it can be used as a cache, memoization, computational framework and, sometimes, as an alternative to GenServer.

Current section

Files

Jump to
agent_map lib agent_map collectable.ex
Raw

lib/agent_map/collectable.ex

defimpl Collectable, for: AgentMap do
def into(am) do
collector_fun = fn
am, {:cont, {key, value}} ->
AgentMap.put(am, key, value, cast: false)
am, :done ->
am
_set, :halt ->
:ok
end
{am, collector_fun}
end
end