fix: back to at least part-parallism, except sqlite
This commit is contained in:
16
lib/bds/rebuild.ex
Normal file
16
lib/bds/rebuild.ex
Normal file
@@ -0,0 +1,16 @@
|
||||
defmodule BDS.Rebuild do
|
||||
@moduledoc false
|
||||
|
||||
def parallel_map(items, mapper, opts \\ []) when is_list(items) and is_function(mapper, 1) do
|
||||
max_concurrency = Keyword.get(opts, :max_concurrency, System.schedulers_online())
|
||||
ordered = Keyword.get(opts, :ordered, true)
|
||||
timeout = Keyword.get(opts, :timeout, :infinity)
|
||||
|
||||
items
|
||||
|> Task.async_stream(mapper, max_concurrency: max_concurrency, ordered: ordered, timeout: timeout)
|
||||
|> Enum.map(fn
|
||||
{:ok, item} -> item
|
||||
{:exit, reason} -> exit(reason)
|
||||
end)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user