Skip to content

Commit

Permalink
add promise_complete? method
Browse files Browse the repository at this point in the history
  • Loading branch information
jimweirich committed Nov 1, 2012
1 parent e768ae7 commit 8bf696d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/rake/thread_pool.rb
Expand Up @@ -40,7 +40,7 @@ def future(*args,&block)

promise_core = lambda do
# can't execute more than once
next unless promise_result.equal?(NOT_SET) && promise_error.equal?(NOT_SET)
next if promise_complete?(promise_result, promise_error)
stat :promise_will_execute, :item_id => promise_worker.object_id
begin
promise_result = block.call(*local_args)
Expand Down Expand Up @@ -83,6 +83,11 @@ def promise.value
promise
end

def promise_complete?(promise_result, promise_error)
! promise_result.equal?(NOT_SET) ||
! promise_error.equal?(NOT_SET)
end

# Waits until the queue of futures is empty and all threads have exited.
def join
@threads_mon.synchronize do
Expand Down

0 comments on commit 8bf696d

Please sign in to comment.