Skip to content

Commit

Permalink
keep list of 'needed?' parents instead of using singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
quix committed Sep 19, 2008
1 parent e333948 commit c374f2d
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions lib/rake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ def invoke(*args)
end
application.parallel_lock.synchronize {
application.parallel_tasks.clear
application.parallel_parent_flags.clear
base_invoke(*args)
application.invoke_parallel_tasks
}
Expand Down Expand Up @@ -610,10 +611,21 @@ def invoke_with_call_chain(task_args, invocation_chain) # :nodoc:
invoke_prerequisites_parallel(task_args, new_chain)
end

if needed?
if application.num_threads == 1
if application.num_threads == 1
#
# single-threaded mode
#
if needed?
execute(task_args)
else
end
else
#
# parallel mode
#
# Either the task knows it's needed or we've marked it as
# such. See next comments.
#
if application.parallel_parent_flags[self] or needed?
# gather tasks for batch execution
application.parallel_tasks[name] = [task_args, prereqs]

Expand All @@ -622,13 +634,9 @@ def invoke_with_call_chain(task_args, invocation_chain) # :nodoc:
# as needed. Files are not created or modified, so the
# the 'needed?' flag does not propagate.
#
unless invocation_chain == InvocationChain::EMPTY or
invocation_chain.value.needed?
invocation_chain.value.instance_eval {
def needed?
true
end
}
unless invocation_chain == InvocationChain::EMPTY
application.
parallel_parent_flags[invocation_chain.value] = true
end
end
end
Expand Down Expand Up @@ -1761,6 +1769,7 @@ module TaskManager
attr_accessor :num_threads
attr_reader :parallel_tasks #:nodoc:
attr_reader :parallel_lock #:nodoc:
attr_reader :parallel_parent_flags #:nodoc:

def initialize
super
Expand All @@ -1772,6 +1781,7 @@ def initialize
@num_threads = 1
@parallel_tasks = Hash.new
@parallel_lock = Mutex.new
@parallel_parent_flags = Hash.new
end

def create_rule(*args, &block)
Expand Down

0 comments on commit c374f2d

Please sign in to comment.