/*
* call-seq:
* mutex.lock => true or false
*
* Attempts to grab the lock and waits if it isn't available.
* Raises +ThreadError+ if +mutex+ was locked by the current thread.
*/
VALUE
rb_mutex_lock(VALUE self)
{
if (rb_mutex_trylock(self) == Qfalse) {
mutex_t *mutex;
rb_thread_t *th = GET_THREAD();
GetMutexPtr(self, mutex);
while (mutex->th != th) {
int interrupted;
BLOCKING_REGION({
interrupted = lock_func(th, mutex);
}, lock_interrupt, mutex);
if (interrupted) {
RUBY_VM_CHECK_INTS();
}
}
}
return self;
}