Class: Farce::Local::LeasePool
- Inherits:
-
Abstract::LeasePool
- Object
- Abstract::LeasePool
- Farce::Local::LeasePool
- Includes:
- Scoped, Shareable::Unfreezable
- Defined in:
- lib/farce/local/lease_pool.rb
Overview
A shareable pool with independent capacity and resources in each scope.
Instance Attribute Summary
Attributes included from Scoped
Attributes inherited from Abstract::LeasePool
Instance Method Summary collapse
-
#initialize(max_size:, scope: :ractor) { ... } ⇒ LeasePool
constructor
Construct an empty pool in each scope.
Methods included from Shareable
Methods inherited from Abstract::LeasePool
#available_count, #checked_out_count, #checkin, #checkout, #creating_count, #size, #try_checkout
Methods included from Internal::Noncopyable
Constructor Details
#initialize(max_size:, scope: :ractor) { ... } ⇒ LeasePool
Construct an empty pool in each scope. Valid scopes are:
:ractor- The value is shared by all threads within the same Ractor.:thread_group- The value is shared by all threads within the same thread group.:thread- The value is shared by all fibers within the same thread.:fiber_storage- The value is shared by all fibers using the same storage. Unless explicitly specified, storage is inherited from the parent fiber for blocking fibers, but not for non-blocking fibers (such as those created by Scheduler#schedule).:fiber- Each fiber has its own independent value.
25 26 27 28 29 30 |
# File 'lib/farce/local/lease_pool.rb', line 25 def initialize(max_size:, scope: :ractor, &factory) validate_configuration!(max_size, factory) @max_size = max_size @factory = Ractor.shareable?(factory) ? factory : Ractor.shareable_proc(&factory) super(scope:, max_size:) end |