Class: SmartCore::Engine::Lock

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_core/engine/lock.rb

Overview

Since:

  • 0.4.0

Instance Method Summary collapse

Constructor Details

#initializevoid

Since:

  • 0.4.0



10
11
12
# File 'lib/smart_core/engine/lock.rb', line 10

def initialize
  @lock = ::Mutex.new
end

Instance Method Details

#synchronize(&block) ⇒ Any

Parameters:

  • block (Block)

Returns:

  • (Any)

Since:

  • 0.4.0



19
20
21
# File 'lib/smart_core/engine/lock.rb', line 19

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