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.



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

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

Instance Method Details

#synchronize(&block) ⇒ Object



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

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