Should pthread attribute attributes exist for the lifetime of the object that uses them, or is it safe to destroy them immediately after using them? For instance:
// Create the mutex attributes. pthread_mutexattr_t attributes; pthread_mutexattr_init( &attributes ); pthread_mutexattr_settype( &attributes, PTHREAD_MUTEX_NORMAL ); // Create the mutex using the attributes from above. pthread_mutex_t mutex; pthread_mutex_init( &mutex, &attributes );
Is it now possible to safely destroy attributes using pthread_mutexattr_destroy (), or is it necessary to wait until the mutex is destroyed using pthread_mutex_destroy ()?
Does the same apply to other pthread objects that use attributes?
source share