Class: Concurrent::Channel::Selector::AfterClause
- Inherits:
-
Object
- Object
- Concurrent::Channel::Selector::AfterClause
- Defined in:
- lib/concurrent-ruby-edge/concurrent/channel/selector/after_clause.rb
Instance Method Summary collapse
- #execute ⇒ undocumented
-
#initialize(seconds, block) ⇒ AfterClause
constructor
A new instance of AfterClause.
Constructor Details
#initialize(seconds, block) ⇒ AfterClause
Returns a new instance of AfterClause.
10 11 12 13 14 |
# File 'lib/concurrent-ruby-edge/concurrent/channel/selector/after_clause.rb', line 10 def initialize(seconds, block) raise ArgumentError.new('timeout must 0.0 or more') if seconds.to_f < 0.0 @end = Concurrent.monotonic_time + seconds.to_f @block = block end |
Instance Method Details
#execute ⇒ undocumented
16 17 18 19 20 21 22 23 |
# File 'lib/concurrent-ruby-edge/concurrent/channel/selector/after_clause.rb', line 16 def execute if Concurrent.monotonic_time > @end result = @block ? @block.call : nil Concurrent::Maybe.just(result) else Concurrent::Maybe.nothing end end |