Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Thread::Mutex#try_lock
() -> bool
mutex.try_lock → true or false
thread_sync.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/thread_sync.rb, line 369
def try_lock
Primitive.rb_mut_trylock
end
Attempts to obtain the lock and returns immediately. Returns true if the lock was granted.