Module: MultiXML::Concurrency Private

Defined in:
lib/multi_xml/concurrency.rb,
sig/multi_xml.rbs

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Catalog of process-wide mutexes used to serialize MultiXML's mutable state. Each mutex protects a distinct piece of state. Callers go through Concurrency.synchronize rather than touching the mutex constants directly so the constants themselves can stay private_constant and the surface of the module is documented in one place.

Constant Summary collapse

MUTEXES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Catalog of mutexes keyed by symbolic name. Each entry maps the public name passed to synchronize to the underlying mutex instance.

Returns:

  • (Hash[Symbol, Thread::Mutex])
{
  # Guards the DEPRECATION_WARNINGS_SHOWN set in MultiXML so the
  # check-then-add pair in warn_deprecation_once doesn't race.
  deprecation_warnings: Mutex.new
}.freeze

Class Method Summary collapse

Class Method Details

.synchronize(name) { ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run a block while holding the named mutex

Parameters:

  • name (Symbol)

    mutex identifier

Yields:

  • block to execute while holding the mutex

Returns:

  • (Object)

    the block's return value

Raises:

  • (KeyError)

    when name does not match a known mutex



27
28
29
# File 'lib/multi_xml/concurrency.rb', line 27

def self.synchronize(name, &)
  MUTEXES.fetch(name).synchronize(&)
end