23 #ifndef OTF2_PTHREAD_LOCKS_H
24 #define OTF2_PTHREAD_LOCKS_H
48 const pthread_mutexattr_t* mutexAttribute );
66 const pthread_mutexattr_t* mutexAttribute );
76 struct OTF2_LockObject
78 pthread_mutex_t mutex;
84 typedef struct OTF2_Pthread_UserData
86 const pthread_mutexattr_t* mutex_attribute;
87 } OTF2_Pthread_UserData;
91 otf2_pthread_lock_release(
void* userData )
93 OTF2_Pthread_UserData* user_data = ( OTF2_Pthread_UserData* )userData;
95 if ( user_data->mutex_attribute )
98 pthread_mutexattr_destroy( ( pthread_mutexattr_t* )user_data->mutex_attribute );
106 otf2_pthread_lock_create(
void* userData,
109 OTF2_Pthread_UserData* user_data = ( OTF2_Pthread_UserData* )userData;
117 *lock = (
OTF2_Lock )malloc(
sizeof( **lock ) );
123 err = pthread_mutex_init( &( *lock )->mutex, user_data->mutex_attribute );
135 otf2_pthread_lock_destroy(
void* userData,
147 err = pthread_mutex_destroy( &lock->mutex );
155 otf2_pthread_lock_lock(
void* userData,
167 err = pthread_mutex_lock( &lock->mutex );
174 otf2_pthread_lock_unlock(
void* userData,
186 err = pthread_mutex_unlock( &lock->mutex );
194 otf2_pthread_lock_release,
195 otf2_pthread_lock_create,
196 otf2_pthread_lock_destroy,
197 otf2_pthread_lock_lock,
198 otf2_pthread_lock_unlock
204 const pthread_mutexattr_t* mutexAttribute )
207 OTF2_Pthread_UserData* user_data = NULL;
216 user_data = ( OTF2_Pthread_UserData* )calloc( 1,
sizeof( *user_data ) );
222 user_data->mutex_attribute = mutexAttribute;
225 &otf2_pthread_locking_callbacks,
237 const pthread_mutexattr_t* mutexAttribute )
240 OTF2_Pthread_UserData* user_data = NULL;
249 user_data = ( OTF2_Pthread_UserData* )calloc( 1,
sizeof( *user_data ) );
255 user_data->mutex_attribute = mutexAttribute;
258 &otf2_pthread_locking_callbacks,
Record reading can continue.
Definition: OTF2_GeneralDefinitions.h:347
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:66
Definition: OTF2_ErrorCodes.h:231
Definition: OTF2_ErrorCodes.h:245
OTF2_ErrorCode
Definition: OTF2_ErrorCodes.h:54
static OTF2_ErrorCode OTF2_Pthread_Archive_SetLockingCallbacks(OTF2_Archive *archive, const pthread_mutexattr_t *mutexAttribute)
Register callbacks to use Pthread mutexes for a OTF2 archive.
OTF2_CallbackCode
Return value to indicate that the record reading should be interrupted.
Definition: OTF2_GeneralDefinitions.h:344
struct OTF2_LockObject * OTF2_Lock
Opaque type for a locking object.
Definition: OTF2_Callbacks.h:545
Signaling an error in the callback.
Definition: OTF2_GeneralDefinitions.h:358
struct OTF2_Archive_struct OTF2_Archive
Keeps all meta-data for an OTF2 archive.
Definition: OTF2_Archive.h:210
struct OTF2_Reader_struct OTF2_Reader
Keeps all necessary information for the reader.
Definition: OTF2_Reader.h:190
Struct which holds all locking callbacks.
Definition: OTF2_Callbacks.h:636
static OTF2_ErrorCode OTF2_Pthread_Reader_SetLockingCallbacks(OTF2_Reader *reader, const pthread_mutexattr_t *mutexAttribute)
Register callbacks to use Pthread mutexes for a OTF2 reader.
OTF2_ErrorCode OTF2_Reader_SetLockingCallbacks(OTF2_Reader *reader, const OTF2_LockingCallbacks *lockingCallbacks, void *lockingData)
Set the locking callbacks for the reader.