mtx_destroy()

Updated: October 28, 2024

Destroy a mutex

Synopsis:

#include <threads.h>

void mtx_destroy( mtx_t* mutex );

Arguments:

mutex
A pointer to the mtx_t object that you want to destroy.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The mtx_destroy() function destroys the unlocked mutex mutex. You can destroy a locked mutex only if you're its owner. An invalid input mutex or an attempt to destroy a mutex locked by another thread results in an unsuccessful mtx_destroy() call.

The mtx_destroy() function calls the pthread_mutex_destroy() function. Any return from this function gets casted to a void pointer in mtx_destroy(). You cannot use the C11 functions interchangeably with the pthread mutex functions.

Note: Once you've destroyed a mutex, don't reuse it without reinitializing it by calling mtx_init().

Classification:

C11

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes
  翻译: