Class | Needle::QueryableMutex
In: | lib/needle/thread.rb
Parent: | Mutex

A subclass of Mutex that allows clients to discover which thread has the mutex locked. This is necessary for (among other things) discovering cycles in the dependency graph of services.

### Methods

lock new self_locked? try_lock unlock

### Public Class methods

new()

Create a new unlocked QueryableMutex.

### Public Instance methods

lock()

Checks to see if the current thread has the mutex locked, and if it does, raises an exception. Otherwise, locks the mutex and sets the locking thread to Thread.current.

self_locked?()

Return `true` if the current thread has locked this mutex.

try_lock()

Attempts to acquire the lock. Returns `true` if the lock was acquired, and `false` if the mutex was already locked.

unlock()

Unlocks the mutex and sets the locking thread to `nil`.

[Validate]