Class: Dry::Effects::Providers::Parallel

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/effects/providers/parallel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stackObject (readonly)

Returns the value of attribute stack.



13
14
15
# File 'lib/dry/effects/providers/parallel.rb', line 13

def stack
  @stack
end

Instance Method Details

#callObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Yield the block with the handler installed



31
32
33
34
# File 'lib/dry/effects/providers/parallel.rb', line 31

def call
  @stack = Frame.stack
  yield
end

#join(xs) ⇒ Object



24
25
26
# File 'lib/dry/effects/providers/parallel.rb', line 24

def join(xs)
  xs.map(&:value!)
end

#parObject



15
16
17
18
19
20
21
22
# File 'lib/dry/effects/providers/parallel.rb', line 15

def par
  stack = self.stack.dup
  proc do |&block|
    ::Concurrent::Promise.execute(executor: executor) do
      Frame.spawn_fiber(stack, &block)
    end
  end
end