try_lock()
public
Attempts to obtain the lock and returns
immediately. Returns true if the lock was granted.
Show source
VALUE
rb_mutex_trylock(VALUE self)
{
rb_mutex_t *mutex = mutex_ptr(self);
VALUE locked = Qfalse;
if (mutex->th == 0) {
rb_thread_t *th = GET_THREAD();
mutex->th = th;
locked = Qtrue;
mutex_locked(th, self);
}
return locked;
}