Class: Farce::Abstract::WeakAtom Abstract

Inherits:
Atom
  • Object
show all
Defined in:
lib/farce/abstract/weak_atom.rb

Overview

This class is abstract.

Common superclass for weak atomic references.

A weak atom does not keep its current value alive. Its value becomes nil after garbage collection when no strong references remain. Collection timing is controlled by the garbage collector. In-flight operations may temporarily retain values they observe. Updates are serialized even when collection changes the observed value.

Instance Method Summary collapse

Methods inherited from Atom

#blank?, #compare_and_set, #compare_by_identity?, #get, #store, #store_if_absent, #swap, #update, #upsert, #value, #value=, #wait_until, #wait_until_changed, #wait_until_match, #wait_until_non_nil, #wait_until_value, #wait_while, #wait_while_match, #wait_while_value

Methods included from Internal::ValueSerialization

#as_extended_json, #as_json, #to_bson, #to_bson_normalized_value, #to_cbor, #to_json, #to_msgpack

Methods included from Value

#blank?, #unwrap, #value

Methods included from Internal::Copyable

#duplicable?

Constructor Details

#initialize(value = nil, compare_by_identity: false) ⇒ WeakAtom

Returns a new instance of WeakAtom.

Parameters:

  • value (BasicObject, nil) (defaults to: nil) —

    the initial value

  • compare_by_identity (Boolean) (defaults to: false) —

    whether comparisons use object identity instead of equality



17
18
19
20
# File 'lib/farce/abstract/weak_atom.rb', line 17

def initialize(value = nil, compare_by_identity: false)
  @atom = internal_atom_class.new(value, compare_by_identity:)
  super()
end