Module: Farce::Local::Scoped

Includes:
Shareable
Included in:
Lazy, Lease, LeaseMap, LeasePool, PriorityQueue, Queue, TimerQueue
Defined in:
lib/farce/local/scoped.rb,
lib/farce/integrations/active_support/map.rb

Overview

Common scope selection and storage for shareable local objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Shareable

#ractor_shareable?

Instance Attribute Details

#scope ⇒ Symbol (readonly)

Returns The scope used to resolve this object's contents.

Returns:

  • (Symbol) —

    The scope used to resolve this object's contents.



87
88
89
# File 'lib/farce/local/scoped.rb', line 87

def scope
  @scope
end

Instance Method Details

#initialize(*arguments, scope: :ractor, **options) ⇒ BasicObject

Constructor arguments configure each scope's independent backing object. Valid scopes are:

  • :ractor - The value is shared by all threads within the same Ractor.
  • :thread_group - The value is shared by all threads within the same thread group.
  • :thread - The value is shared by all fibers within the same thread.
  • :fiber_storage - The value is shared by all fibers using the same storage. Unless explicitly specified, storage is inherited from the parent fiber for blocking fibers, but not for non-blocking fibers (such as those created by Scheduler#schedule).
  • :fiber - Each fiber has its own independent value.

Parameters:

  • arguments (Array<BasicObject>) —

    positional arguments for the backing object

  • options (Hash{Symbol => BasicObject}) —

    keyword arguments for the backing object

  • scope (Symbol) (defaults to: :ractor) —

    The storage scope. Defaults to :ractor.



94
95
96
# File 'lib/farce/local/scoped.rb', line 94

def initialize(*arguments, scope: :ractor, **options)
  initialize_scoped(arguments, options, scope:)
end