Class: EY::Serverside::Future
- Inherits:
-
Object
show all
- Extended by:
- Dataflow
- Defined in:
- lib/engineyard-serverside/future.rb,
lib/engineyard-serverside/futures/dataflow.rb,
lib/engineyard-serverside/futures/celluloid.rb
Constant Summary
Constants included
from Dataflow
Dataflow::UnificationError, Dataflow::VERSION
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Dataflow
barrier, by_need, flow, included, local, need_later, unify
Constructor Details
#initialize(&block) ⇒ Future
Returns a new instance of Future.
12
13
14
|
# File 'lib/engineyard-serverside/future.rb', line 12
def initialize(&block)
@block = block
end
|
Class Method Details
.call(blocks) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/engineyard-serverside/futures/dataflow.rb', line 9
def self.call(blocks)
futures = map(blocks)
need_laters = futures.map do |future|
need_later { future.result }
end
barrier(*need_laters)
futures
end
|
.map(blocks) ⇒ Object
4
5
6
|
# File 'lib/engineyard-serverside/future.rb', line 4
def self.map(blocks)
blocks.map { |block| new(&block) }
end
|
.success?(futures) ⇒ Boolean
8
9
10
|
# File 'lib/engineyard-serverside/future.rb', line 8
def self.success?(futures)
futures.empty? || futures.all? {|f| f.success?}
end
|
Instance Method Details
21
22
23
|
# File 'lib/engineyard-serverside/futures/dataflow.rb', line 21
def call
@block.call
end
|
#error? ⇒ Boolean
24
25
26
|
# File 'lib/engineyard-serverside/future.rb', line 24
def error?
!success?
end
|
16
17
18
|
# File 'lib/engineyard-serverside/future.rb', line 16
def result
@result ||= call
end
|
#success? ⇒ Boolean
20
21
22
|
# File 'lib/engineyard-serverside/future.rb', line 20
def success?
result.success?
end
|