adding tcp_messages, concurrent queue, types refactoring
This commit is contained in:
@@ -29,22 +29,28 @@ void mutex_destroy(mutex_t mutex) {
|
||||
}
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
#include <pthread.h>
|
||||
|
||||
struct st_mutex {
|
||||
pthread_mutex_t handle;
|
||||
};
|
||||
|
||||
mutex_t mutex_create() {
|
||||
mutex_t mutex = malloc(sizeof(mutex_t));
|
||||
pthread_mutex_init(mutex, 0);
|
||||
mutex_t mutex = malloc(sizeof(struct st_mutex));
|
||||
pthread_mutex_init(&mutex->handle, 0);
|
||||
return mutex;
|
||||
}
|
||||
|
||||
void mutex_lock(mutex_t mutex) {
|
||||
pthread_mutex_lock(mutex);
|
||||
pthread_mutex_lock(&mutex->handle);
|
||||
}
|
||||
|
||||
void mutex_unlock(mutex_t mutex) {
|
||||
pthread_mutex_unlock(mutex);
|
||||
pthread_mutex_unlock(&mutex->handle);
|
||||
}
|
||||
|
||||
void mutex_destroy(mutex_t mutex) {
|
||||
pthread_mutex_destroy(mutex);
|
||||
pthread_mutex_destroy(&mutex->handle);
|
||||
free(mutex);
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user