Sha256: f183f1499c8b44f163c3329d742527e61fd9baa8c30d7475e635b34f9bb4e89d

Contents?: true

Size: 536 Bytes

Versions: 1

Compression:

Stored size: 536 Bytes

Contents

module Frankenpins
  # A transition queue
  # Items added to the queue are
  # executed in order
  class TransitionQueue
    def initialize
      @queue = Queue.new
      @debug = false
    end

    def push(transition)
      puts "E: #{transition.type} #{transition}" if @debug
      @queue.push(transition)
    end

    def start!
      Thread.new do
        loop do
          transition = @queue.pop
          puts "D: #{transition.type} #{transition}" if @debug
          transition.perform!
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
frankenpins-0.3.0 lib/frankenpins/transition_queue.rb