diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-04-27 16:14:07 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-04-27 16:14:07 +1000 |
commit | 55bb30899899d1e6f34e85d87909d5108d085adb (patch) | |
tree | ffc06fb5677b6f9d5289187267a7cd517efe2e3e /src/platform | |
parent | c72440f89cfabe0c7752f9105cfc244a79016965 (diff) |
defining api for mutex/thread
Diffstat (limited to 'src/platform')
-rw-r--r-- | src/platform/mutex.c | 9 | ||||
-rw-r--r-- | src/platform/mutex.h | 26 | ||||
-rw-r--r-- | src/platform/thread.c | 0 | ||||
-rw-r--r-- | src/platform/thread.h | 17 |
4 files changed, 52 insertions, 0 deletions
diff --git a/src/platform/mutex.c b/src/platform/mutex.c new file mode 100644 index 0000000..9735483 --- /dev/null +++ b/src/platform/mutex.c @@ -0,0 +1,9 @@ +#include "mutex.h" + +#if defined(CEL_PLATFORM_LINUX) || defined(CEL_PLATFORM_MAC) +// TODO: implement in terms of pthreads +#endif + +#if defined (CEL_PLATFORM_WINDOWS) +// TODO: implement using win32 api +#endif
\ No newline at end of file diff --git a/src/platform/mutex.h b/src/platform/mutex.h new file mode 100644 index 0000000..0552ea2 --- /dev/null +++ b/src/platform/mutex.h @@ -0,0 +1,26 @@ +/** + * @file mutex.h + * @author your name (you@domain.com) + * @brief + * @version 0.1 + * @date 2024-04-27 + * + * @copyright Copyright (c) 2024 + * + */ +#include <stdbool.h> + +typedef struct cel_mutex cel_mutex; + +cel_mutex mutex_create(); + +void mutex_destroy(cel_mutex* mutex); + +/** @brief Blocks until the mutex can be acquired. if returns false then an error occurred and can be checked (TODO) */ +bool mutex_lock(cel_mutex* mutex); + +/** @brief Tries to acquire the mutex like `mutex_lock` but returns immediately if the mutex has already been locked */ +bool mutex_try_lock(cel_mutex* mutex); + +/** @brief Releases a mutex. If it is already unlocked then does nothing */ +void mutex_unlock(cel_mutex* mutex);
\ No newline at end of file diff --git a/src/platform/thread.c b/src/platform/thread.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/platform/thread.c diff --git a/src/platform/thread.h b/src/platform/thread.h new file mode 100644 index 0000000..a3560cb --- /dev/null +++ b/src/platform/thread.h @@ -0,0 +1,17 @@ +/** + * @file thread.h + * @author your name (you@domain.com) + * @brief + * @version 0.1 + * @date 2024-04-27 + * + * @copyright Copyright (c) 2024 + * + */ + +typedef struct cel_thread cel_thread; + +cel_thread thread_create(); +void thread_destroy(cel_thread* thread); + +// join
\ No newline at end of file |