Class: Proco::Future
Instance Method Summary
collapse
Methods included from MT::Base
#broadcast, #do_when, #signal, #synchronize, #try_when, #wait_until
Constructor Details
#initialize ⇒ Future
Returns a new instance of Future.
20
21
22
23
24
|
# File 'lib/proco/future.rb', line 20
def initialize
super()
@state = :wait
@return = nil
end
|
Instance Method Details
#get ⇒ Object
5
6
7
8
9
10
11
12
13
|
# File 'lib/proco/future.rb', line 5
def get
do_when(proc { @state != :wait }) do
if @state == :ok
return @return
else
raise @return
end
end
end
|
#inspect ⇒ Object
15
16
17
|
# File 'lib/proco/future.rb', line 15
def inspect
"Future=#{@state}"
end
|
#update ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/proco/future.rb', line 27
def update
begin
@return = yield
@state = :ok
rescue Exception => e
@return = e
@state = :fail
end
broadcast
end
|