Method: Mutex#try_lock
- Defined in:
- thread_sync.c
#try_lock ⇒ Boolean
Attempts to obtain the lock and returns immediately. Returns true if the lock was granted.
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'thread_sync.c', line 202 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; } |