Class: Concurrent::Channel::Buffer::Dropping — Concurrent

Class List Method List File List

# Class: Concurrent::Channel::Buffer::Dropping

Inherits:
  Buffered
  - Object
  - Synchronization::LockableObject
  - Base
  - Buffered
  - Concurrent::Channel::Buffer::Dropping
  show all
Defined in:
  lib/concurrent/channel/buffer/dropping.rb

## Overview

A non-blocking, buffered buffer of fixed maximum capacity. When the maximum capacity is reached subsequent #put and #offer operations will complete but the `put` item will be discarded; no transfer will occur.

## Instance Attribute Summary (collapse)

- - (undocumented) capacity inherited from Base readonly

  The maximum number of values which can be #put onto the buffer it becomes full.

## Instance Method Summary (collapse)

- - (Boolean) blocking?

  Predicate indicating if this buffer will block #put operations once it reaches its maximum capacity.

- - (Boolean) full?

  Predicate indicating if the buffer is full.

- - (Boolean) offer(item)

  Put an item onto the buffer is possible.

- - (Boolean) put(item)

  Put an item onto the buffer if possible.

## Constructor Details

This class inherits a constructor from Concurrent::Channel::Buffer::Base

## Instance Attribute Details

### - (`undocumented`) capacity Originally defined in class Base

The maximum number of values which can be #put onto the buffer it becomes full.

## Instance Method Details

### - (`Boolean`) blocking?

Predicate indicating if this buffer will block #put operations once it reaches its maximum capacity.

Always returns `false`.

Returns:

- (`Boolean`) —

  true if this buffer blocks else false

    35
    36
    37
    # File 'lib/concurrent/channel/buffer/dropping.rb', line 35

    def blocking?
      false
    end

### - (`Boolean`) full?

Predicate indicating if the buffer is full.

Always returns `false`.

Returns:

- (`Boolean`) —

  true if this buffer is full else false

    # File 'lib/concurrent/channel/buffer/dropping.rb', line 27

### - (`Boolean`) offer(item)

Put an item onto the buffer is possible. If the buffer is open but unable to add an item, probably due to being full, the method will return immediately. Similarly, the method will return immediately when the buffer is closed. A return value of `false` does not necessarily indicate that the buffer is closed, just that the item could not be added.

When the buffer is full, this method will return `true` immediately but the item will be discarded. The item will not be placed into the buffer (no transfer will occur).

Parameters:

- item (`Object`) —

  the item/value to put onto the buffer.

Returns:

- (`Boolean`) —

  true if the item was added to the buffer else false (always false when closed).

    # File 'lib/concurrent/channel/buffer/dropping.rb', line 20

### - (`Boolean`) put(item)

Put an item onto the buffer if possible. If the buffer is open but not able to accept the item the calling thread will block until the item can be put onto the buffer.

When the buffer is full, this method will return `true` immediately but the item will be discarded. The item will not be placed into the buffer (no transfer will occur).

Parameters:

- item (`Object`) —

  the item/value to put onto the buffer.

Returns:

- (`Boolean`) —

  true if the item was added to the buffer else false (always false when closed).

    # File 'lib/concurrent/channel/buffer/dropping.rb', line 13