Class: Farce::Unshared::Queue

Inherits:
Abstract::Queue show all
Includes:
Farce::Unshareable
Defined in:
lib/farce/unshared/queue.rb

Overview

A FIFO queue that stores and returns values directly.

Instance Attribute Summary

Attributes inherited from Abstract::Queue

#capacity, #num_waiting, #size

Instance Method Summary collapse

Methods included from Farce::Unshareable

#ractor_shareable?

Methods inherited from Abstract::Queue

#age_tracking?, #clear, #close, #closed?, #deq, #duplicable?, #empty?, #enq, #full?, #generation, #length, #max, #oldest_age, #oldest_enqueued_at, #pop, #push, #seal, #sealed?, #try_pop, #try_push, #wait_pop, #wait_push

Constructor Details

#initialize(capacity: 1024, track_age: false) ⇒ Queue

Returns a new instance of Queue.

This method is abstract.

Subclasses may add additional parameters to this method.

Parameters:

  • capacity (Integer, nil) (defaults to: 1024) —

    The maximum number of items the queue can hold. If nil, the queue is unbounded.

    The default may vary for subclasses. Most notably, priority and timer queues default to nil.

  • track_age (Boolean) (defaults to: false) —

    Whether to track enqueue age and queue generations.



13
14
15
16
# File 'lib/farce/unshared/queue.rb', line 13

def initialize(capacity: 1024, fiber_wait: :auto, track_age: false)
  @queue = Internal::UnsharedQueue.new(capacity:, fiber_wait:, track_age:)
  super()
end

Instance Method Details

#mode ⇒ Symbol

The default mode used to transfer values between Ractors.

Returns:

  • (Symbol)
  • (Symbol) —

    always returns :local



20
# File 'lib/farce/unshared/queue.rb', line 20

def mode = :local