Method: ConcurrentSHM::Mutex#lock

Defined in:
ext/concurrent-shm/posix.c

#locknil

Locks the mutex, blocking until the mutex becomes available, if necessary.

Returns:

  • (nil)

Raises:

  • (Errno::EDEADLK)

    if the current thread already owns the mutex

  • (Errno::EAGAIN)

    if the mutex could not be acquired because the maximum number of recursive locks for mutex has been exceeded



616
617
618
619
620
621
622
623
624
625
626
627
# File 'ext/concurrent-shm/posix.c', line 616

static VALUE mutex_lock(VALUE self)
{
    if (mutex_try_lock(self) == Qtrue) {
        return Qnil;
    }

    mutex_t * mu = value_as_mutex(self);
    int err = (int)(uintptr_t)rb_thread_call_without_gvl((void * (*)(void *))pthread_mutex_lock, &mu->shared->mu, NULL, NULL);

    rb_check_syserr_fail_strf(err, err, "pthread_mutex_lock()");
    return Qnil;
}