Sha256: b08aaf258f8282be78c9621a5e89bff17fed9472324df1b1c017babb661a324e
Contents?: true
Size: 541 Bytes
Versions: 7
Compression:
Stored size: 541 Bytes
Contents
require 'fiber' class RestCore::Future::FutureFiber < RestCore::Future def initialize *args super self.fibers = [] end def wrap Fiber.new{ yield }.resume end def wait fibers << Fiber.current Fiber.yield until loaded? # it might be resumed by some other futures! end def resume return if fibers.empty? current_fibers = fibers.dup fibers.clear current_fibers.each{ |f| next unless f.alive? next_tick{ f.resume } } resume end protected attr_accessor :fibers end
Version data entries
7 entries across 7 versions & 1 rubygems