Class: SmartCore::Container::ArbitaryLock Private

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_core/container/arbitary_lock.rb

Overview

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

Since:

  • 0.7.0

Instance Method Summary collapse

Constructor Details

#initializevoid

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.

Since:

  • 0.7.0



10
11
12
# File 'lib/smart_core/container/arbitary_lock.rb', line 10

def initialize
  @lock = Mutex.new
end

Instance Method Details

#thread_safe(&block) ⇒ Any

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.

Parameters:

  • block (Proc)

Returns:

  • (Any)

Since:

  • 0.7.0



19
20
21
# File 'lib/smart_core/container/arbitary_lock.rb', line 19

def thread_safe(&block)
  @lock.owned? ? yield : @lock.synchronize(&block)
end