Class: Litesupport::Mutex

Inherits:
Object
  • Object
show all
Defined in:
lib/litestack/litesupport.rb

Instance Method Summary collapse

Constructor Details

#initializeMutex

Returns a new instance of Mutex.



68
69
70
# File 'lib/litestack/litesupport.rb', line 68

def initialize
  @mutex = Thread::Mutex.new
end

Instance Method Details

#synchronize(&block) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/litestack/litesupport.rb', line 72

def synchronize(&block)
  if Litescheduler.backend == :threaded || Litescheduler.backend == :iodine
    @mutex.synchronize { block.call }
  else
    block.call
  end
end