instance method
Thread::Mutex#sleep
(?nil) -> bot
(::Time::_Timeout duration) -> ::Integer
mutex.sleep(timeout = nil) → number or nil
thread_sync.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/thread_sync.rb, line 147
def sleep(timeout = nil)
Primitive.rb_mut_sleep(timeout)
end
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.