From 7779175be4dd3bf52d0df05cdbdfa6df38e777ad Mon Sep 17 00:00:00 2001 From: yoshie <802632-arkandos@users.noreply.gitlab.com> Date: Sun, 14 Sep 2025 21:40:13 +0200 Subject: [PATCH] :memo: document the monitor we add. --- src/crew.gleam | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/crew.gleam b/src/crew.gleam index f7a42b2..45cfa10 100644 --- a/src/crew.gleam +++ b/src/crew.gleam @@ -319,6 +319,9 @@ pub fn parallel_map( timeout timeout: Int, with fun: fn(a) -> b, ) -> List(b) { + // we don't want to do the multiple subject trick here since that is + // potentially O(n^2) + let unordered: List(#(Int, b)) = list |> list.index_map(fn(item, index) { fn() { #(index, fun(item)) } }) @@ -429,6 +432,9 @@ pub fn subscribe(pool: Name(PoolMsg)) -> Channel(a) { /// Work results arrive in completion order. It is your responsibility to handle /// the lifecycle and ordering. /// +/// This adds a specific monitor to the selector to handle the case where the pool +/// goes down, so it's better to prefer few channels over many. +/// /// ## Panics /// - If a worker or the pool crashes while executing work, the selector will /// panic with details about the crash. -- 2.51.2