Created
June 22, 2010 15:55
-
-
Save kagminjeong/448661 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' | |
require 'ruote/storage/hash_storage' | |
# preparing the engine | |
engine = Ruote::Engine.new( | |
Ruote::Worker.new( | |
Ruote::HashStorage.new)) | |
# workflow definitions | |
first = Ruote.process_definition :name => 'first' do | |
participant :first | |
end | |
second = Ruote.process_definition :name => 'second' do | |
participant :second | |
end | |
# participant definitions | |
engine.register_participant :first do | |
sleep 1 | |
puts 'first' | |
end | |
engine.register_participant :second do | |
sleep 2 | |
puts 'second' | |
end | |
# launching | |
one = engine.launch(first) | |
two = engine.launch(second) | |
# waiting | |
t = Thread.new do | |
engine.wait_for(two) | |
end | |
# make sure the above waiting thread has a chance to run | |
sleep 0.2 | |
# now we overwrite interests in ruote logger. | |
# above thread will never finish. | |
# comment this line to have the process terminate | |
engine.wait_for(one) | |
# waits forever | |
t.join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment