Created
August 25, 2009 22:02
-
-
Save dakrone/175066 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # Stripped down Child | |
| pid = fork | |
| unless pid | |
| DRb.start_service | |
| # fetch the TupleSpace over DRb using a proxy object | |
| ts = Rinda::TupleSpaceProxy.new(DRbObject.new_with_uri('druby://127.0.0.1:53421')) | |
| loop do | |
| # break if no more items in the queue | |
| break if done_work and ts.read_all([:enum, nil, nil]).empty? | |
| item = ts.take([:enum, nil, nil]) | |
| result = block.call(item[2]) | |
| # return result, item[1] is the result's index in an array or hash | |
| ts.write([:result, item[1], result]) | |
| end | |
| DRb.stop_service | |
| exit! | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment