Sha256: a844e5513bb650ea8139ce24125a226f4b34fa9e7867f2c63f227c816bc66730
Contents?: true
Size: 604 Bytes
Versions: 4
Compression:
Stored size: 604 Bytes
Contents
# frozen_string_literal: true module Dry module Effects module Providers class Async < Provider[:async] option :tasks, default: -> { ::Hash.new } include Dry::Equalizer(:tasks) attr_reader :stack def async(block) @tasks[block] = block end def await(task) Frame.spawn_fiber(stack, &@tasks.delete(task)) end # Yield the block with the handler installed # # @api private def call @stack = Frame.stack super nil end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems