Sha256: 6490b15ccf0f691b3164fe23525114a68d1b94875b49cd7f70ea2e90bde9f910

Contents?: true

Size: 650 Bytes

Versions: 3

Compression:

Stored size: 650 Bytes

Contents

# frozen_string_literal: true
require_relative 'builder/all'
require_relative 'builder/any'
require_relative 'builder/race'
require_relative 'builder/task'

class Fiber
  module Collector    
    class Builder
      def initialize
        @blocks = []
      end

      def schedule(&block)
        @blocks << block
        self
      end

      def and(...)
        schedule(...)
      end

      def all(timeout: nil)
        All.new(@blocks).wait(timeout)
      end
      
      def any(timeout: nil)
        Any.new(@blocks).wait(timeout)
      end

      def race(timeout: nil)
        Race.new(@blocks).wait(timeout)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fiber-collector-1.0.0 lib/fiber/collector/builder.rb
fiber-collector-0.1.1 lib/fiber/collector/builder.rb
fiber-collector-0.1.0 lib/fiber/collector/builder.rb