summaryrefslogtreecommitdiff
path: root/src/common/thread.h
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-03-14 00:19:22 +0100
committerHaru <haru@dotalux.com>2016-07-12 20:58:42 +0200
commitc4a3a3f59e5720b300077c3d34aa7f4ecdd76400 (patch)
tree0321ed1375fd67c1789f744e3500df79cdb40833 /src/common/thread.h
parentb9578c1d8ce54b48363e297b1c56cdea0ed72821 (diff)
downloadhercules-c4a3a3f59e5720b300077c3d34aa7f4ecdd76400.tar.gz
hercules-c4a3a3f59e5720b300077c3d34aa7f4ecdd76400.tar.bz2
hercules-c4a3a3f59e5720b300077c3d34aa7f4ecdd76400.tar.xz
hercules-c4a3a3f59e5720b300077c3d34aa7f4ecdd76400.zip
Various changes to the thread interface
Mostly stylistic changes. Cleaned up documentation. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common/thread.h')
-rw-r--r--src/common/thread.h47
1 files changed, 29 insertions, 18 deletions
diff --git a/src/common/thread.h b/src/common/thread.h
index bde35f738..c668afbb4 100644
--- a/src/common/thread.h
+++ b/src/common/thread.h
@@ -23,42 +23,56 @@
#include "common/hercules.h"
+/** @file
+ * Basic Threading abstraction (for pthread / win32 based systems).
+ */
+
/* Opaque Types */
struct thread_handle; ///< Thread handle.
typedef void *(*threadFunc)(void *); ///< Thread entry point function.
+/* Enums */
+
+/// Thread priority
enum thread_priority {
THREADPRIO_LOW = 0,
THREADPRIO_NORMAL,
THREADPRIO_HIGH
};
+/// The thread interface
struct thread_interface {
+ /// Interface initialization.
+ void (*init) (void);
+
+ /// Interface finalization.
+ void (*final) (void);
+
/**
* Creates a new Thread.
*
- * @param entyPoint Thread's entry point.
- * @param param General purpose parameter, would be given as
- * parameter to the thread's entry point.
+ * @param enty_point Thread's entry point.
+ * @param param General purpose parameter, would be given as
+ * parameter to the thread's entry point.
*
* @return The created thread object.
* @retval NULL in vase of failure.
*/
- struct thread_handle *(*create) (threadFunc entryPoint, void *param);
+ struct thread_handle *(*create) (threadFunc entry_point, void *param);
/**
* Creates a new Thread (with more creation options).
*
- * @param entyPoint Thread's entry point.
- * @param param General purpose parameter, would be given as
- * parameter to the thread's entry point.
- * @param szStack Stack Size in bytes.
- * @param prio Priority of the Thread in the OS scheduler.
+ * @param enty_point Thread's entry point.
+ * @param param General purpose parameter, would be given as
+ * parameter to the thread's entry point.
+ * @param stack_size Stack Size in bytes.
+ * @param prio Priority of the Thread in the OS scheduler.
*
* @return The created thread object.
* @retval NULL in case of failure.
*/
- struct thread_handle *(*createEx) (threadFunc entryPoint, void *param, size_t szStack, enum thread_priority prio);
+ struct thread_handle *(*create_opt) (threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio);
/**
* Destroys the given Thread immediately.
@@ -100,13 +114,13 @@ struct thread_interface {
/**
* Waits for the given thread to terminate.
*
- * @param[in] handle The thread to wait (join) for.
- * @param[out] out_Exitcode Pointer to return the exit code of the
- * given thread after termination (optional).
+ * @param[in] handle The thread to wait (join) for.
+ * @param[out] out_exit_code Pointer to return the exit code of the
+ * given thread after termination (optional).
*
* @retval true if the given thread has been terminated.
*/
- bool (*wait) (struct thread_handle *handle, void **out_exitCode);
+ bool (*wait) (struct thread_handle *handle, void **out_exit_code);
/**
* Sets the given priority in the OS scheduler.
@@ -131,15 +145,12 @@ struct thread_interface {
* the remaining time of the slice to another thread.
*/
void (*yield) (void);
-
- void (*init) (void);
- void (*final) (void);
};
#ifdef HERCULES_CORE
void thread_defaults(void);
#endif // HERCULES_CORE
-HPShared struct thread_interface *thread;
+HPShared struct thread_interface *thread; ///< Pointer to the thread interface.
#endif /* COMMON_THREAD_H */