I just did some final fixes and a proper release of Nest which is an implementation of some parts of structured concurrency that focuses on ease of use and on leveraging existing constructs. It doesn’t try to be a dedicated background task runner but rather something quick to easily get shit done concurrently or in parallel.
You get
- waiting for everything started to complete
- stack traces that propagate through nests that have the whole execution chain
- back-pressure & limited concurrency when you need it
- simple interaction with execution contexts. Want to execute in a dedicated thread pool? Just pass in a parallel context.
You currently don’t get
- other approaches to high load, like dropping requests.
- limited concurrency in the context of recursive spawns - that would need a variant that limits concurrency but don’t apply any backpressure.
- Cancellation and any feature that depends on cancellation to work well. This needs upstream support in crystal to be done well.
- a `map_span` variant that keep track of the order.
Examples:
Nest.each_span do |pool|
pool.spawn { do_work }
pool.spawn { do_other_work }
end
values = Nest.map_span(Int32) do |pool|
pool.spawn { 1 }
pool.spawn { 2 }
pool.spawn { 3 }
end