From 55bb30899899d1e6f34e85d87909d5108d085adb Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Sat, 27 Apr 2024 16:14:07 +1000 Subject: defining api for mutex/thread --- src/platform/mutex.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/platform/mutex.h (limited to 'src/platform/mutex.h') 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 + +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 -- cgit v1.2.3-70-g09d2