-
-
Save anonymous/884853 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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