Class: Phronomy::Runtime::PoolRegistry Private
- Inherits:
-
Object
- Object
- Phronomy::Runtime::PoolRegistry
- Defined in:
- lib/phronomy/runtime/pool_registry.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Registry and lifecycle manager for BlockingAdapterPool instances.
Maintains one unnamed "default" pool (accessed via #default_pool) and an arbitrary number of named pools (accessed via #named_pool). All pools are shut down together by #shutdown.
Instance Method Summary collapse
-
#default_pool(pool_size: 10, queue_size: 100) ⇒ BlockingAdapterPool
private
Returns (or lazily creates) the unnamed default pool.
-
#initialize ⇒ PoolRegistry
constructor
private
A new instance of PoolRegistry.
-
#named_pool(name, size: 10, queue_size: 100) ⇒ BlockingAdapterPool
private
Returns (or lazily creates) a named pool.
-
#shutdown ⇒ void
private
Shuts down the default pool and all named pools.
Constructor Details
#initialize ⇒ PoolRegistry
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of PoolRegistry.
12 13 14 15 16 |
# File 'lib/phronomy/runtime/pool_registry.rb', line 12 def initialize @mutex = Mutex.new @pools = {} @default = nil end |
Instance Method Details
#default_pool(pool_size: 10, queue_size: 100) ⇒ BlockingAdapterPool
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns (or lazily creates) the unnamed default pool.
23 24 25 26 27 28 29 |
# File 'lib/phronomy/runtime/pool_registry.rb', line 23 def default_pool(pool_size: 10, queue_size: 100) @default ||= BlockingAdapterPool.new( name: :default, pool_size: pool_size, queue_size: queue_size ) end |
#named_pool(name, size: 10, queue_size: 100) ⇒ BlockingAdapterPool
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns (or lazily creates) a named pool.
37 38 39 40 41 42 43 44 45 |
# File 'lib/phronomy/runtime/pool_registry.rb', line 37 def named_pool(name, size: 10, queue_size: 100) @mutex.synchronize do @pools[name.to_sym] ||= BlockingAdapterPool.new( name: name, pool_size: size, queue_size: queue_size ) end end |
#shutdown ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Shuts down the default pool and all named pools.
50 51 52 53 54 |
# File 'lib/phronomy/runtime/pool_registry.rb', line 50 def shutdown @default&.shutdown pools = @mutex.synchronize { @pools.values.dup } pools.each(&:shutdown) end |