Kore
Loading...
Searching...
No Matches
thread.h File Reference

Supports the creation and destruction of threads. More...

#include <kinc/global.h>
#include <kinc/backend/thread.h>

Go to the source code of this file.

Data Structures

struct  kinc_thread

Typedefs

typedef struct kinc_thread kinc_thread_t

Functions

KINC_FUNC void kinc_threads_init (void)
 Initializes the threading system. This has to be called before calling any kinc_thread functions.
KINC_FUNC void kinc_threads_quit (void)
 Shuts down the threading system.
KINC_FUNC void kinc_thread_init (kinc_thread_t *thread, void(*func)(void *param), void *param)
 Starts a thread via the provided function.
KINC_FUNC void kinc_thread_wait_and_destroy (kinc_thread_t *thread)
 Waits for the thread to complete execution and then destroys it.
KINC_FUNC bool kinc_thread_try_to_destroy (kinc_thread_t *thread)
 Attempts to destroy a thread.
KINC_FUNC void kinc_thread_set_name (const char *name)
 Assigns a name to the current thread which will then show up in debuggers and profilers.
KINC_FUNC void kinc_thread_sleep (int milliseconds)
 Puts the current thread to sleep.

Detailed Description

Supports the creation and destruction of threads.

Function Documentation

◆ kinc_thread_init()

KINC_FUNC void kinc_thread_init ( kinc_thread_t * thread,
void(* func )(void *param),
void * param )

Starts a thread via the provided function.

Parameters
threadThe thread-object to initialize with the new thread
funcThe function used to start a new thread
paramA parameter that is passed to the thread-function when the thread starts running

◆ kinc_thread_set_name()

KINC_FUNC void kinc_thread_set_name ( const char * name)

Assigns a name to the current thread which will then show up in debuggers and profilers.

Parameters
nameThe name to assign to the thread

◆ kinc_thread_sleep()

KINC_FUNC void kinc_thread_sleep ( int milliseconds)

Puts the current thread to sleep.

Parameters
millisecondsHow long to sleep

◆ kinc_thread_try_to_destroy()

KINC_FUNC bool kinc_thread_try_to_destroy ( kinc_thread_t * thread)

Attempts to destroy a thread.

Parameters
threadThe thread to destroy
Returns
Returns if the thread is still running and therefore couldn't be destroyed

◆ kinc_thread_wait_and_destroy()

KINC_FUNC void kinc_thread_wait_and_destroy ( kinc_thread_t * thread)

Waits for the thread to complete execution and then destroys it.

Parameters
threadThe thread to destroy

◆ kinc_threads_quit()

KINC_FUNC void kinc_threads_quit ( void )

Shuts down the threading system.

Returns