Name
pthread_mutex_trylock
- attempt to lock a mutex without blocking
Library
libc_r.lib
libpthread.lib
libthr.lib
Synopsis
|
int
pthread_mutex_trylock (pthread_mutex_t *mutex);
|
Return values
If successful,
pthread_mutex_trylock
will return zero, otherwise an error number will be returned to
indicate the error.
Detailed description
The
pthread_mutex_trylock
function locks
mutex.
If the mutex is already locked,
pthread_mutex_trylock
will not block waiting for the mutex, but will return an error condition.
Examples
int rc;
pthread_mutex_t mutex;
rc = pthread_mutex_trylock(&mutex);
switch (rc)
{
case 0:
printf ("Locked successfully\n");
break;
case EAGAIN:
printf ("could not lock, try later.....\n");
break;
}
Errors
The
pthread_mutex_trylock
function will fail if:
[EINVAL]
|
|
The value specified by
mutex
is invalid.
|
[EAGAIN]
|
|
Mutex
is already locked.
|
[ENOSYS]
|
|
If locking is not supported for this
mutex
kind.
|
See also
pthread_mutex_destroy,
pthread_mutex_init,
pthread_mutex_lock,
pthread_mutex_unlock
Feedback
For additional information or queries on this page send feedback
© 2005-2007 Nokia
|
|