Sha256: 597c90c3c8eb5a4eaf4d0a0068feea90f7c112fe8f0ca06f114b1970298f266b

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

require 'concurrent/channel/buffer/base'

module Concurrent
  class Channel
    module Buffer

      # 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.
      class Dropping < Buffered

        # @!method put(item)
        #   @!macro channel_buffer_put
        #
        #   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).

        # @!method offer(item)
        #   @!macro channel_buffer_offer
        #
        #   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).

        # @!method full?
        #   @!macro channel_buffer_full_question
        #
        #   Always returns `false`.

        # @!macro channel_buffer_blocking_question
        #
        # Always returns `false`.
        def blocking?
          false
        end

        private

        # @!macro channel_buffer_full_question
        def ns_full?
          false
        end

        # @!macro channel_buffer_put
        def ns_put_onto_buffer(item)
          @buffer.push(item) unless @buffer.size == size
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
concurrent-ruby-edge-0.2.0.pre3 lib/concurrent/channel/buffer/dropping.rb