Class: Farce::LeasePool

Inherits:
Abstract::LeasePool show all
Includes:
Shareable::Unfreezable
Defined in:
lib/farce/lease_pool.rb

Overview

A Ractor-shareable pool that moves resources on checkout and checkin.

Examples:

Reusing an object across Ractors

pool = Farce::LeasePool.new(max_size: 2) { [] }
result = Farce::Ractor.new(pool) do |shared|
  shared.checkout do |items|
    items << :worker
    items.length
  end
end.value

result # => 1

Instance Attribute Summary

Attributes inherited from Abstract::LeasePool

#max_size

Method Summary

Methods included from Shareable

#initialize, #ractor_shareable?

Methods inherited from Abstract::LeasePool

#available_count, #checked_out_count, #checkin, #checkout, #creating_count, #initialize, #size, #try_checkout

Methods included from Internal::Noncopyable

#duplicable?