#pragma once #include #include /*! \file thread.h \brief Supports the creation and destruction of threads. */ #ifdef __cplusplus extern "C" { #endif typedef struct kinc_thread { kinc_thread_impl_t impl; } kinc_thread_t; /// /// Initializes the threading system. This has to be called before calling any kinc_thread functions. /// KINC_FUNC void kinc_threads_init(void); /// /// Shuts down the threading system. /// /// /// KINC_FUNC void kinc_threads_quit(void); /// /// Starts a thread via the provided function. /// /// The thread-object to initialize with the new thread /// The function used to start a new thread /// A parameter that is passed to the thread-function when the thread starts running KINC_FUNC void kinc_thread_init(kinc_thread_t *thread, void (*func)(void *param), void *param); /// /// Waits for the thread to complete execution and then destroys it. /// /// The thread to destroy KINC_FUNC void kinc_thread_wait_and_destroy(kinc_thread_t *thread); /// /// Attempts to destroy a thread. /// /// The thread to destroy /// Returns if the thread is still running and therefore couldn't be destroyed KINC_FUNC bool kinc_thread_try_to_destroy(kinc_thread_t *thread); /// /// Assigns a name to the current thread which will then show up in debuggers and profilers. /// /// The name to assign to the thread KINC_FUNC void kinc_thread_set_name(const char *name); /// /// Puts the current thread to sleep. /// /// How long to sleep KINC_FUNC void kinc_thread_sleep(int milliseconds); #ifdef __cplusplus } #endif