Class: Farce::Local::PriorityQueue
- Inherits:
-
Abstract::PriorityQueue
- Object
- Abstract::Queue
- Abstract::PriorityQueue
- Farce::Local::PriorityQueue
- Includes:
- Scoped, Shareable::Unfreezable
- Defined in:
- lib/farce/local/priority_queue.rb
Overview
A shareable priority queue with independent mutable storage in each scope.
Instance Attribute Summary
Attributes included from Scoped
Attributes inherited from Abstract::PriorityQueue
Attributes inherited from Abstract::Queue
#capacity, #num_waiting, #size
Instance Method Summary collapse
-
#initialize(capacity: nil, default_priority: 0, order: :ascending, scope: :ractor, track_age: false) ⇒ PriorityQueue
constructor
Valid scopes are: *
:ractor- The value is shared by all threads within the same Ractor. -
#mode ⇒ Symbol
Always returns
:local.
Methods included from Shareable
Methods inherited from Abstract::PriorityQueue
#delete, #first_priority, #last_priority, #peek, #pop, #push, #try_pop, #try_push, #wait_pop
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: nil, default_priority: 0, order: :ascending, scope: :ractor, track_age: false) ⇒ PriorityQueue
Returns a new instance of PriorityQueue.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/farce/local/priority_queue.rb', line 21 def initialize( capacity: nil, default_priority: 0, order: :ascending, scope: :ractor, track_age: false, fiber_wait: :auto ) unless Ractor.shareable?(default_priority) raise Ractor::IsolationError, "default_priority must be Ractor-shareable" end @order = normalize_order(order) @default_priority = default_priority @reverse_order = @order == :descending super(capacity:, scope:, track_age:, fiber_wait:) end |
Instance Method Details
#mode ⇒ Symbol
Returns always returns :local.
36 |
# File 'lib/farce/local/priority_queue.rb', line 36 def mode = :local |