Skip to content

Instantly share code, notes, and snippets.

@cadwallion
Forked from Mirai/gist:2379753
Created April 13, 2012 20:19
Show Gist options
  • Save cadwallion/2379899 to your computer and use it in GitHub Desktop.
Save cadwallion/2379899 to your computer and use it in GitHub Desktop.
require 'work_queue'
wq = WorkQueue.new(5)
i = 1
%w{foo bar baz bun}.each do |file|
i2 = i
wq.enqueue_b do
#move file to another directory
ImportFile.new(file, i2).run
end
i += 1
end
wq.join
puts "I: #{i}"
class InputFile
def initialize
puts "In InputFile"
end
def run
puts "Processing file"
end
end
# OUTPUT
#
# DevNull work_queue ruby work_queue_test.rb
# I: 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment