Class: Delayer::Deferred::Promise
Constant Summary
Deferredable::NodeSequence::AWAIT, Deferredable::NodeSequence::AWAIT_C, Deferredable::NodeSequence::BURST_OUT, Deferredable::NodeSequence::CALL_CHILD, Deferredable::NodeSequence::CONNECTED, Deferredable::NodeSequence::FRESH, Deferredable::NodeSequence::GENOCIDE, Deferredable::NodeSequence::GRAFT, Deferredable::NodeSequence::GRAFT_C, Deferredable::NodeSequence::PASS, Deferredable::NodeSequence::PASS_C, Deferredable::NodeSequence::RESERVED, Deferredable::NodeSequence::RESERVED_C, Deferredable::NodeSequence::ROTTEN, Deferredable::NodeSequence::RUN, Deferredable::NodeSequence::RUN_C, Deferredable::NodeSequence::SEQUENCE_LOCK, Deferredable::NodeSequence::STOP, Deferredable::NodeSequence::WAIT
Instance Attribute Summary
#child
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Tools
fail, next, pass, sleep, system, trap, when
#call, #fail
#add_awaited, #add_child, #add_child_observer, #awaited, #cancel, #enter_pass, #exit_pass, #has_awaited?, #has_child?, #next, #reserve_activate, #trap
#activated?, #change_sequence, #on_sequence_changed, #sequence, #spoiled?
#graph, #graph_child, #graph_draw, #graph_save
#+@, #enter_await, #exit_await
Constructor Details
#initialize(name:) ⇒ Promise
Returns a new instance of Promise.
45
46
47
48
|
# File 'lib/delayer/deferred/promise.rb', line 45
def initialize(name:)
super()
@name = name
end
|
Class Method Details
.delayer ⇒ Object
25
26
27
|
# File 'lib/delayer/deferred/promise.rb', line 25
def delayer
::Delayer
end
|
.new(stop = false, name: caller_locations(1,1).first.to_s, &block) ⇒ Object
11
12
13
14
15
16
|
# File 'lib/delayer/deferred/promise.rb', line 11
def new(stop=false, name: caller_locations(1,1).first.to_s, &block)
result = promise = super(name: name)
result = promise.next(&block) if block_given?
promise.call(true) unless stop
result
end
|
.Promise ⇒ Object
21
22
23
|
# File 'lib/delayer/deferred/promise.rb', line 21
def Promise
self
end
|
.Thread ⇒ Object
18
19
|
# File 'lib/delayer/deferred/promise.rb', line 18
def Thread
@thread_class ||= gen_thread_class end
|
.to_s ⇒ Object
29
30
31
|
# File 'lib/delayer/deferred/promise.rb', line 29
def to_s
"#{self.delayer}.Promise"
end
|
Instance Method Details
#activate(response) ⇒ Object
50
51
52
53
54
|
# File 'lib/delayer/deferred/promise.rb', line 50
def activate(response)
change_sequence(:activate)
change_sequence(:complete)
response
end
|
#ancestor ⇒ Object
60
61
62
|
# File 'lib/delayer/deferred/promise.rb', line 60
def ancestor
self
end
|
#inspect ⇒ Object
56
57
58
|
# File 'lib/delayer/deferred/promise.rb', line 56
def inspect
"#<#{self.class} seq:#{sequence.name}>"
end
|
#parent=(chainable) ⇒ Object
64
65
66
|
# File 'lib/delayer/deferred/promise.rb', line 64
def parent=(chainable)
fail Error, "#{self.class} can't has parent."
end
|