123456789_123456789_123456789_123456789_123456789_

Class: Concurrent::Channel::Selector::PutClause

Relationships & Source Files
Inherits: Object
Defined in: lib/concurrent-ruby-edge/concurrent/channel/selector/put_clause.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(channel, message, block) ⇒ PutClause

[ GitHub ]

  
# File 'lib/concurrent-ruby-edge/concurrent/channel/selector/put_clause.rb', line 9

def initialize(channel, message, block)
  @channel = channel
  @message = message
  @block = block
end

Instance Method Details

#execute

[ GitHub ]

  
# File 'lib/concurrent-ruby-edge/concurrent/channel/selector/put_clause.rb', line 15

def execute
  if @channel.offer?(@message).just?
    result = @block ? @block.call : nil
    Concurrent::Maybe.just(result)
  else
    Concurrent::Maybe.nothing
  end
end