Skip to content

Instantly share code, notes, and snippets.

View benstiglitz's full-sized avatar

Benjamin Stiglitz benstiglitz

View GitHub Profile
@benstiglitz
benstiglitz / futures.rb
Created December 15, 2009 22:15 — forked from patrickt/futures.rb
now with threads
include Dispatch
class Future
def initialize(&block)
@@queue_count ||= 0
Thread.current[:futures_queue] ||= Queue.new("org.macruby.futures-#{Thread.current.object_id}")
@group = Group.new
Thread.current[:futures_queue].async(@group) { @value = block[] }
end