Skip to content

Commit 154e1ba

Browse files
committed
Add documentation
1 parent 657f808 commit 154e1ba

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/concurrent/obligation.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,30 @@ def incomplete?
4242
[:unscheduled, :pending].include? state
4343
end
4444

45+
# @returns [Object] see Dereferenceable#deref
4546
def value(timeout = nil)
4647
wait timeout
4748
deref
4849
end
4950

51+
# wait until Obligation is #complete?
52+
# @param [Numeric] timeout the maximum time in second to wait.
53+
# @return [Obligation] self
5054
def wait(timeout = nil)
5155
event.wait(timeout) if timeout != 0 && incomplete?
5256
self
5357
end
5458

59+
# wait until Obligation is #complete?
60+
# @param [Numeric] timeout the maximum time in second to wait.
61+
# @return [Obligation] self
62+
# @raise [Exception] when #rejected? it raises #reason
5563
def no_error!(timeout = nil)
5664
wait(timeout).tap { raise self if rejected? }
5765
end
5866

67+
# @raise [Exception] when #rejected? it raises #reason
68+
# @returns [Object] see Dereferenceable#deref
5969
def value!(timeout = nil)
6070
wait(timeout)
6171
if rejected?

lib/concurrent/observable.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def add_observer(*args, &block)
1010
observers.add_observer(*args, &block)
1111
end
1212

13+
# as #add_observer but it can be used for chaning
1314
# @return [Observable] self
1415
def with_observer(*args, &block)
1516
add_observer *args, &block

0 commit comments

Comments
 (0)