Skip to content

Instantly share code, notes, and snippets.

@gustavoanatoly
Created November 5, 2012 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gustavoanatoly/4017432 to your computer and use it in GitHub Desktop.
Save gustavoanatoly/4017432 to your computer and use it in GitHub Desktop.
Recursive lock Ruby
/**
* Line 227
*/
static void
native_mutex_initialize(pthread_mutex_t *lock)
{
/*
* Creating mutex attribute with Mutex Recursive
* option, to allow self lock.
*/
pthread_mutexattr_t attribute;
pthread_mutexattr_init(&attribute);
pthread_mutexattr_settype(&attribute, PTHREAD_MUTEX_RECURSIVE);
int r = pthread_mutex_init(lock, &attribute);
mutex_debug("init", lock);
if (r != 0) {
rb_bug_errno("pthread_mutex_init", r);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment