Skip to content

Instantly share code, notes, and snippets.

/t.rb

Created March 24, 2011 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/884853 to your computer and use it in GitHub Desktop.
Save anonymous/884853 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'ruote'
engine = Ruote::Engine.new(Ruote::Worker.new(Ruote::HashStorage.new))
pdef = Ruote.process_definition do
alpha
end
class Ruote::StorageParticipant
def next
find { |wi| wi.fields['__reserved__'] != true }
end
def reserve(wi)
wi.fields['__reserved__'] = true
update(wi)
end
def reserve_next
wi = self.next
reserve(wi)
wi
end
end
engine.register_participant 'alpha', Ruote::StorageParticipant
5.times do
engine.launch(pdef)
end
sleep 3
p engine.storage_participant.reserve_next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment