Sha256: 207f1a014e8352785b708d51573869f13d0af8c6fc96349e52ec5a1da08c68df
Contents?: true
Size: 742 Bytes
Versions: 2
Compression:
Stored size: 742 Bytes
Contents
# frozen_string_literal: true require 'concurrent/promise' require 'dry/effects/provider' module Dry module Effects module Providers class Parallel < Provider[:parallel] option :executor, default: -> { :io } attr_reader :stack def par stack = self.stack.dup proc do |&block| ::Concurrent::Promise.execute(executor: executor) do Frame.spawn_fiber(stack, &block) end end end def join(xs) xs.map(&:value!) end # Yield the block with the handler installed # # @api private def call(stack) @stack = stack super end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dry-effects-0.1.1 | lib/dry/effects/providers/parallel.rb |
dry-effects-0.1.0 | lib/dry/effects/providers/parallel.rb |