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

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

Instance Method Summary collapse

Constructor Details

#initialize(channel, message, block) ⇒ PutClause

Returns a new instance of PutClause.



9
10
11
12
13
# File 'lib-edge/concurrent/channel/selector/put_clause.rb', line 9

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

Instance Method Details

#executeundocumented



15
16
17
18
19
20
21
22
# File 'lib-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