summaryrefslogtreecommitdiffhomepage
path: root/SDK/Libraries/CoreSystem/Headers/Thread.h
diff options
context:
space:
mode:
authorAmlal <amlalelmahrouss@icloud.com>2024-06-06 10:27:55 +0000
committerAmlal <amlalelmahrouss@icloud.com>2024-06-06 10:27:55 +0000
commit4e75e05a20ddd0dbca982e8f3bc2ea8043ed3a3f (patch)
tree95409c0e32b644578b94a5c230417da684d79dc9 /SDK/Libraries/CoreSystem/Headers/Thread.h
parentf5081a8f9a8537ad5be5d639955cd1d0e68a9e1d (diff)
parent9994b8f3f88131f41be1061fb0947177e66dc7b0 (diff)
Merged in MHR-23 (pull request #14)
Draft: MHR-23
Diffstat (limited to 'SDK/Libraries/CoreSystem/Headers/Thread.h')
-rw-r--r--SDK/Libraries/CoreSystem/Headers/Thread.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/SDK/Libraries/CoreSystem/Headers/Thread.h b/SDK/Libraries/CoreSystem/Headers/Thread.h
new file mode 100644
index 00000000..15b40df3
--- /dev/null
+++ b/SDK/Libraries/CoreSystem/Headers/Thread.h
@@ -0,0 +1,47 @@
+/* -------------------------------------------
+
+ Copyright SoftwareLabs
+
+------------------------------------------- */
+
+//
+// Created by Amlal on 3/18/24
+//
+
+#ifndef __THREAD__
+#define __THREAD__
+
+#include <Headers/Defines.h>
+
+#define kThreadErrorExit (-33)
+
+/// @brief Thread reference.
+typedef QWordType ThreadRef;
+
+/// @brief Main application thread.
+CS_EXTERN_C ThreadRef kMainThread;
+
+typedef VoidType (*ThreadEntrypointKind)(VoidType);
+
+/// @brief Creates a new thread, and runs the code.
+/// @param threadName the thread's name.
+/// @param threadStart where to start.
+/// @return
+CS_EXTERN_C ThreadRef CSThreadCreate(const CharacterTypeUTF8* threadName, ThreadEntrypointKind threadStart);
+
+/// @brief Dispoes the thread, and exits with code kThreadErrorExit
+/// @param ref the thread reference.
+/// @return nothing.
+CS_EXTERN_C VoidType CSThreadRelease(ThreadRef ref);
+
+/// @brief Waits for the thread to complete.
+/// @param ref the thread reference.
+/// @return nothing.
+CS_EXTERN_C VoidType CSThreadJoin(ThreadRef ref);
+
+/// @brief Yields the current thread.
+/// @param ref the thead reference.
+/// @return
+CS_EXTERN_C VoidType CSThreadYield(ThreadRef ref);
+
+#endif // __THREAD__