Class: Farce::Lease

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

Overview

A Ractor-shareable lease that moves one resource on checkout and checkin.

Examples:

Reusing an object across Ractors

lease = Farce::Lease.new { [] }
finished = Farce::Port.new
Farce::Ractor.new(lease, finished) do |shared, result|
  size = shared.checkout do |items|
    items << :processed
    items.length
  end
  result << size
end

finished.receive # => 1
lease.checkout { |items| items.dup } # => [:processed]

Method Summary

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