Class: Rake::Promise

Inherits:
Object
  • Object
show all
Defined in:
lib/rake/opt/current_invocation_chain/patches/rake/promise.rb

Defined Under Namespace

Classes: Fake

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, &block) ⇒ Promise

Create a promise to do the chore specified by the block. Overrides by adding @parent



7
8
9
10
11
12
13
14
15
# File 'lib/rake/opt/current_invocation_chain/patches/rake/promise.rb', line 7

def initialize(args, &block)
  @mutex = Mutex.new
  @result = NOT_SET
  @error = NOT_SET
  @args = args
  @block = block
  @invocation_chain = nil
  @parent = Thread.current.promise
end

Instance Attribute Details

#invocation_chainObject

Returns the value of attribute invocation_chain.



2
3
4
# File 'lib/rake/opt/current_invocation_chain/patches/rake/promise.rb', line 2

def invocation_chain
  @invocation_chain
end

#parentObject (readonly)

Returns the value of attribute parent.



3
4
5
# File 'lib/rake/opt/current_invocation_chain/patches/rake/promise.rb', line 3

def parent
  @parent
end

Instance Method Details

#__chore__Object



17
# File 'lib/rake/opt/current_invocation_chain/patches/rake/promise.rb', line 17

alias_method :__chore__, :chore

#chore(*args, &block) ⇒ Object

Properly set the parent thread



20
21
22
23
24
25
# File 'lib/rake/opt/current_invocation_chain/patches/rake/promise.rb', line 20

def chore(*args, &block)
  old_promise = Thread.current.promise
  Thread.current.promise = self
  __chore__(*args, &block)
  Thread.current.promise = old_promise
end