23 #ifndef OTF2_PTHREAD_LOCKS_H
24 #define OTF2_PTHREAD_LOCKS_H
53 const pthread_mutexattr_t* mutexAttribute );
73 const pthread_mutexattr_t* mutexAttribute );
83 struct OTF2_LockObject
85 pthread_mutex_t mutex;
91 typedef struct OTF2_Pthread_UserData
93 const pthread_mutexattr_t* mutex_attribute;
94 } OTF2_Pthread_UserData;
98 otf2_pthread_lock_release(
void* userData )
100 OTF2_Pthread_UserData* user_data = ( OTF2_Pthread_UserData* )userData;
102 if ( user_data->mutex_attribute )
105 pthread_mutexattr_destroy( ( pthread_mutexattr_t* )user_data->mutex_attribute );
113 otf2_pthread_lock_create(
void* userData,
116 OTF2_Pthread_UserData* user_data = ( OTF2_Pthread_UserData* )userData;
124 *lock = (
OTF2_Lock )malloc(
sizeof( **lock ) );
130 err = pthread_mutex_init( &( *lock )->mutex, user_data->mutex_attribute );
142 otf2_pthread_lock_destroy(
void* userData,
154 err = pthread_mutex_destroy( &lock->mutex );
162 otf2_pthread_lock_lock(
void* userData,
174 err = pthread_mutex_lock( &lock->mutex );
181 otf2_pthread_lock_unlock(
void* userData,
193 err = pthread_mutex_unlock( &lock->mutex );
201 otf2_pthread_lock_release,
202 otf2_pthread_lock_create,
203 otf2_pthread_lock_destroy,
204 otf2_pthread_lock_lock,
205 otf2_pthread_lock_unlock
211 const pthread_mutexattr_t* mutexAttribute )
214 OTF2_Pthread_UserData* user_data = NULL;
223 user_data = ( OTF2_Pthread_UserData* )calloc( 1,
sizeof( *user_data ) );
229 user_data->mutex_attribute = mutexAttribute;
232 &otf2_pthread_locking_callbacks,
244 const pthread_mutexattr_t* mutexAttribute )
247 OTF2_Pthread_UserData* user_data = NULL;
256 user_data = ( OTF2_Pthread_UserData* )calloc( 1,
sizeof( *user_data ) );
262 user_data->mutex_attribute = mutexAttribute;
265 &otf2_pthread_locking_callbacks,
Record reading can continue.
Definition: OTF2_GeneralDefinitions.h:352
OTF2_ErrorCode OTF2_Archive_SetLockingCallbacks(OTF2_Archive *archive, const OTF2_LockingCallbacks *lockingCallbacks, void *lockingData)
Set the locking callbacks for the archive.
Main include file for applications using OTF2.
Definition: OTF2_ErrorCodes.h:65
Definition: OTF2_ErrorCodes.h:230
Definition: OTF2_ErrorCodes.h:244
OTF2_ErrorCode
Definition: OTF2_ErrorCodes.h:53
static OTF2_ErrorCode OTF2_Pthread_Archive_SetLockingCallbacks(OTF2_Archive *archive, const pthread_mutexattr_t *mutexAttribute)
Register callbacks to use Pthread mutexes for an OTF2 archive.
OTF2_CallbackCode
Return value to indicate that the record reading should be interrupted.
Definition: OTF2_GeneralDefinitions.h:349
struct OTF2_LockObject * OTF2_Lock
Opaque type for a locking object.
Definition: OTF2_Callbacks.h:552
Signaling an error in the callback.
Definition: OTF2_GeneralDefinitions.h:363
struct OTF2_Archive_struct OTF2_Archive
Keeps all meta-data for an OTF2 archive.
Definition: OTF2_Archive.h:220
struct OTF2_Reader_struct OTF2_Reader
Keeps all necessary information for the reader.
Definition: OTF2_Reader.h:193
Struct which holds all locking callbacks.
Definition: OTF2_Callbacks.h:643
static OTF2_ErrorCode OTF2_Pthread_Reader_SetLockingCallbacks(OTF2_Reader *reader, const pthread_mutexattr_t *mutexAttribute)
Register callbacks to use Pthread mutexes for an OTF2 reader.
OTF2_ErrorCode OTF2_Reader_SetLockingCallbacks(OTF2_Reader *reader, const OTF2_LockingCallbacks *lockingCallbacks, void *lockingData)
Set the locking callbacks for the reader.