/*
* Document-method: try_lock
* call-seq: try_lock
*
* Attempts to obtain the lock and returns immediately. Returns +true+ if the
* lock was granted.
*
*/
static VALUE
rb_mutex_try_lock(VALUE self)
{
Mutex *mutex;
Data_Get_Struct(self, Mutex, mutex);
if (RTEST(mutex->owner))
return Qfalse;
mutex->owner = rb_thread_current();
return Qtrue;
}