Class: Concurrent::Channel::Selector::TakeClause
- Inherits:
-
Object
- Object
- Concurrent::Channel::Selector::TakeClause
- Defined in:
- lib/concurrent-ruby-edge/concurrent/channel/selector/take_clause.rb
Instance Method Summary collapse
- #execute ⇒ undocumented
-
#initialize(channel, block) ⇒ TakeClause
constructor
A new instance of TakeClause.
Constructor Details
#initialize(channel, block) ⇒ TakeClause
Returns a new instance of TakeClause.
9 10 11 12 |
# File 'lib/concurrent-ruby-edge/concurrent/channel/selector/take_clause.rb', line 9 def initialize(channel, block) @channel = channel @block = block end |
Instance Method Details
#execute ⇒ undocumented
14 15 16 17 18 19 20 |
# File 'lib/concurrent-ruby-edge/concurrent/channel/selector/take_clause.rb', line 14 def execute if (result = @channel.poll?).just? Concurrent::Maybe.just(@block.call(result.value)) else Concurrent::Maybe.nothing end end |