Class: Expeditor::RichFuture
- Inherits:
-
Concurrent::Future
- Object
- Concurrent::Future
- Expeditor::RichFuture
- Defined in:
- lib/expeditor/rich_future.rb
Instance Method Summary collapse
- #executed? ⇒ Boolean
- #fail(e) ⇒ Object
- #get ⇒ Object
- #get_or_else(&block) ⇒ Object
- #safe_execute(*args) ⇒ Object
- #safe_fail(e) ⇒ Object
- #safe_set(v) ⇒ Object
- #set(v) ⇒ Object
Instance Method Details
#executed? ⇒ Boolean
40 41 42 |
# File 'lib/expeditor/rich_future.rb', line 40 def executed? not unscheduled? end |
#fail(e) ⇒ Object
32 33 34 |
# File 'lib/expeditor/rich_future.rb', line 32 def fail(e) super(e) end |
#get ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/expeditor/rich_future.rb', line 6 def get wait if rejected? raise reason else value end end |
#get_or_else(&block) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/expeditor/rich_future.rb', line 15 def get_or_else(&block) wait if rejected? block.call else value end end |
#safe_execute(*args) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/expeditor/rich_future.rb', line 44 def safe_execute(*args) if args.empty? begin execute rescue Exception => e fail(e) end else super(*args) end end |
#safe_fail(e) ⇒ Object
36 37 38 |
# File 'lib/expeditor/rich_future.rb', line 36 def safe_fail(e) fail(e) unless complete? end |
#safe_set(v) ⇒ Object
28 29 30 |
# File 'lib/expeditor/rich_future.rb', line 28 def safe_set(v) set(v) unless complete? end |
#set(v) ⇒ Object
24 25 26 |
# File 'lib/expeditor/rich_future.rb', line 24 def set(v) complete(true, v, nil) end |