Skip to content
instance method

Thread::Mutex#sleep

(?nil) -> bot
(::Time::_Timeout duration) -> ::Integer
mutex.sleep(timeout = nil) → number or nil

Releases the lock and sleeps timeout seconds if it is given and non-nil or forever. Raises ThreadError if mutex wasn’t locked by the current thread.

When the thread is next woken up, it will attempt to reacquire the lock.

Note that this method can wakeup without explicit Thread#wakeup call. For example, receiving signal and so on.

Returns the slept time in seconds if woken up, or nil if timed out.

See also #owned? #synchronize #locked? #try_lock also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1