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

Class List Method List File List

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

Inherits:
  Object
  - Object
  - Concurrent::Channel::Selector::PutClause
  show all
Defined in:
  lib/concurrent/channel/selector/put_clause.rb

## Instance Method Summary (collapse)

- - (undocumented) execute
- - (PutClause) initialize(channel, message, block) constructor

  A new instance of PutClause.

## Constructor Details

### - (`PutClause`) initialize(channel, message, block)

Returns a new instance of PutClause

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

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

## Instance Method Details

### - (`undocumented`) execute

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