Class: Farce::Strict::LeasePool

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

Overview

A Ractor-shareable pool that stores shareable resources directly. Factory results and checkin replacements must be shareable. They are not automatically frozen. Other references remain usable during checkout, so callers must honor the checkout when accessing mutable resources.

Examples:

Reusing shareable resources with bounded concurrency

pool = Farce::Strict::LeasePool.new(max_size: 2) { Farce::Strict::Map.new }
pool.checkout { |state| state[:uses] = (state[:uses] || 0) + 1 }
pool.checkout { |state| state[:uses] } # => 1

Instance Attribute Summary

Attributes inherited from Abstract::LeasePool

#max_size

Method Summary

Methods included from Farce::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?