diff options
author | sanine <sanine.not@pm.me> | 2022-08-26 12:42:30 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-08-26 12:42:30 -0500 |
commit | bde3e4f1bb7b8f8abca0884a7d994ee1c17a66b1 (patch) | |
tree | 825ff3669a38ec247bcc9b575a4a4ceb81534d35 /src/mutex.h | |
parent | 8ec3f8e82acd70410515550fd1790ee5827aafdb (diff) |
refactor: move mossrose.h to include/ dir
Diffstat (limited to 'src/mutex.h')
-rw-r--r-- | src/mutex.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/mutex.h b/src/mutex.h new file mode 100644 index 0000000..84d1f63 --- /dev/null +++ b/src/mutex.h @@ -0,0 +1,28 @@ +#ifndef MOSSROSE_MUTEX_H +#define MOSSROSE_MUTEX_H + + +#ifdef WIN32 +#include <windows.h> +typedef HANDLE mossrose_mutex_t; +#else +#include <pthread.h> +typedef pthread_mutex_t mossrose_mutex_t; +#endif + +/* initialize a mutex */ +void mossrose_mutex_init(mossrose_mutex_t *mutex); + +/* lock a mutex, hanging until locked */ +void mossrose_mutex_lock(mossrose_mutex_t *mutex); + +/* attempt to lock a mutex. returns 0 on success and 1 otherwise */ +int mossrose_mutex_trylock(mossrose_mutex_t *mutex); + +/* unlock a mutex */ +void mossrose_mutex_unlock(mossrose_mutex_t *mutex); + +/* destroy a mutex */ +void mossrose_mutex_destroy(mossrose_mutex_t *mutex); + +#endif |