Class: RactorQueue
- Inherits:
-
Object
- Object
- RactorQueue
- Includes:
- Interface
- Defined in:
- lib/ractor_queue/errors.rb,
lib/ractor_queue/version.rb,
lib/ractor_queue/interface.rb,
lib/ractor_queue/ractor_queue.rb
Defined Under Namespace
Modules: Interface Classes: Error, NotShareableError, TimeoutError
Constant Summary collapse
- VERSION =
"0.1.0"- EMPTY =
Public sentinel returned by try_pop when the queue is empty. Use equal? (identity) to check — never == — so that nil is an unambiguous payload.
entry = q.try_pop return if entry.equal?(RactorQueue::EMPTY) EMPTY_SENTINEL
Class Method Summary collapse
Methods included from Interface
#empty?, #full?, #pop, #push, #size, #try_pop, #try_push
Class Method Details
.new(capacity:, validate_shareable: false) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/ractor_queue/ractor_queue.rb', line 14 def self.new(capacity:, validate_shareable: false) instance = super(capacity) instance.instance_variable_set(:@validate_shareable, validate_shareable) # Make the queue instance itself Ractor-shareable. This deep-freezes the Ruby # wrapper object. The C++ AtomicQueueB2 buffer is not affected by Ruby's freeze. Ractor.make_shareable(instance) instance end |