class RSpec::Support::ReentrantMutex

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/rspec/support/reentrant_mutex.rbs

class RSpec::Support::ReentrantMutex
  def exit: () -> RSpec::Support::Mutex
  def exit: () -> RSpec::Support::Mutex
  def initialize: () -> void
end

@private
dne - ruby-doc.org/core-1.9.0/Mutex.html<br>exists - ruby-doc.org/core-1.9.1/Mutex.html<br>Depends on Mutex, but Mutex is only available as part of core since 1.9.1:
Based on Monitor as of 2.2 -
while allowing the thread with the lock to reenter that section.
Allows a thread to lock out other threads from a critical section of code,

def enter

def enter
  @mutex.lock unless @mutex.owned?
  @count += 1
end

def enter

def enter
  @mutex.lock if @owner != Thread.current
  @owner = Thread.current
  @count += 1
end

def exit

Experimental RBS support (using type sampling data from the type_fusion project).

def exit: () -> RSpec::Support::Mutex

This signature was generated using 2 samples from 1 application.

def exit
  unless @mutex.owned?
    raise ThreadError, "Attempt to unlock a mutex which is locked by another thread/fiber"
  end
  @count -= 1
  @mutex.unlock if @count == 0
end

def exit

Experimental RBS support (using type sampling data from the type_fusion project).

def exit: () -> RSpec::Support::Mutex

This signature was generated using 2 samples from 1 application.

def exit
  @count -= 1
  return unless @count == 0
  @owner = nil
  @mutex.unlock
end

def initialize

Experimental RBS support (using type sampling data from the type_fusion project).

def initialize: () -> void

This signature was generated using 1 sample from 1 application.

def initialize
  @owner = nil
  @count = 0
  @mutex = Mutex.new
end

def synchronize

def synchronize
  enter
  yield
ensure
  exit
end