Module: Farce::Shareable::Native

Includes:
Farce::Shareable, Internal::Freeze::Native
Included in:
Abstract::Port, Counter, Flag, Lock
Defined in:
lib/farce/shareable.rb

Overview

A native object that publishes its initialized payload without structural freezing. Requires a backend that already implements safe publication and frozen checks. Including this module alone cannot make an ordinary Ruby object shareable. Native subclasses must not add Ruby instance variables on CRuby.

Examples:

Extend a counter while preserving native publication

class Tally < Farce::Counter
  include Farce::Shareable::Native

  def increment_twice = increment(2)
end

tally = Tally.new
tally.frozen? # => false
Ractor.shareable?(tally) # => true
tally.freeze
tally.increment_twice # raises FrozenError

Method Summary

Methods included from Farce::Shareable

#initialize, #ractor_shareable?