Module: LLM::Lock

Defined in:
lib/llm/lock.rb

Overview

The Lock module provides named locks that are globally accessible and only usable from Ractor.main. The module will noop when given any other Ractor other than main.

Class Method Summary collapse

Class Method Details

.synchronize(name, &block)

This method returns an undefined value.

Provides a thread-safe lock

Parameters:

  • name (Symbol) —

    The name of the lock

  • block (Proc) —

    The block to execute within the lock



26
27
28
29
30
31
32
# File 'lib/llm/lock.rb', line 26

def self.synchronize(name, &block)
  if Ractor.main?
    @monitors[name].synchronize(&block)
  else
    nil
  end
end