File size: 1,229 Bytes
fd49381 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
#include <stdlib.h>
#include <pthread.h>
#include "mallocvar.h"
#include "xmlrpc-c/lock.h"
#include "xmlrpc-c/lock_pthread.h"
static lockAcquireFn acquire;
static void
acquire(struct lock * const lockP) {
pthread_mutex_t * const mutexP = lockP->implementationP;
pthread_mutex_lock(mutexP);
}
static lockReleaseFn release;
static void
release(struct lock * const lockP) {
pthread_mutex_t * const mutexP = lockP->implementationP;
pthread_mutex_unlock(mutexP);
}
static lockDestroyFn destroy;
static void
destroy(struct lock * const lockP) {
pthread_mutex_t * const mutexP = lockP->implementationP;
pthread_mutex_destroy(mutexP);
free(mutexP);
free(lockP);
}
struct lock *
xmlrpc_lock_create_pthread(void) {
struct lock * lockP;
MALLOCVAR(lockP);
if (lockP) {
pthread_mutex_t * mutexP;
MALLOCVAR(mutexP);
if (mutexP) {
pthread_mutex_init(mutexP, NULL);
lockP->implementationP = mutexP;
lockP->acquire = &acquire;
lockP->release = &release;
lockP->destroy = &destroy;
} else {
free(lockP);
lockP = NULL;
}
}
return lockP;
}
|