Sha256: 621d7a808b9e274e9a48ab804b645b1843f7ed349365fd32962cd26a000b12b9

Contents?: true

Size: 409 Bytes

Versions: 3

Compression:

Stored size: 409 Bytes

Contents

class Fiber
  module Collector
    class Task
      attr_reader :state, :error, :result

      def initialize(proc)
        @state = :waiting
        @proc = proc
      end

      def done?
        @state == :done
      end

      def run
        @state = :running
        @result = @proc.call
      rescue StandardError => e
        @error = e
      ensure
        @state = :done
      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/task.rb
fiber-collector-0.1.1 lib/fiber/collector/builder/task.rb
fiber-collector-0.1.0 lib/fiber/collector/builder/task.rb