Class: Concurrent::Channel::Selector::TakeClause

Inherits:
Object
  • Object
show all
Defined in:
lib/concurrent-ruby-edge/concurrent/channel/selector/take_clause.rb

Instance Method Summary collapse

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

#executeundocumented



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