Class: Farce::Strict::Lease

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

Overview

A Ractor-shareable lease that stores a shareable resource directly. Construction and checkin reject non-shareable resources without freezing them. Checkout coordinates callers. Other references remain usable, so callers must honor the checkout when accessing a mutable resource.

Examples:

Coordinating several changes to shareable state

lease = Farce::Strict::Lease.new { Farce::Strict::Map.new }
lease.checkout do |state|
  state[:status] = :ready
  state[:generation] = 1
end
lease.checkout { |state| state[:status] } # => :ready

Method Summary

Methods included from Farce::Shareable

#initialize, #ractor_shareable?

Methods inherited from Abstract::Lease

#available?, #checked_out?, #checkin, #checkout, #initialize, #owned?, #retire, #retired?, #try_checkout

Methods included from Internal::Noncopyable

#duplicable?