Kohi Game Engine
kthread.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "containers/queue.h"
4 #include "defines.h"
5 
11 typedef struct kthread {
16 
17 // A function pointer to be invoked when the thread starts.
18 typedef u32 (*pfn_thread_start)(void *);
19 
28 KAPI b8 kthread_create(pfn_thread_start start_function_ptr, void *params, b8 auto_detach, kthread *out_thread);
29 
34 
38 KAPI void kthread_detach(kthread *thread);
39 
43 KAPI void kthread_cancel(kthread *thread);
44 
51 
60 
66 
71 KAPI void kthread_sleep(kthread *thread, u64 ms);
72 
This file contains global type definitions which are used throughout the entire engine and applicatio...
#define KAPI
Import/export qualifier.
Definition: defines.h:205
unsigned int u32
Unsigned 32-bit integer.
Definition: defines.h:25
_Bool b8
8-bit boolean type
Definition: defines.h:58
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:28
KAPI void kthread_destroy(kthread *thread)
KAPI void kthread_sleep(kthread *thread, u64 ms)
KAPI b8 kthread_wait_timeout(kthread *thread, u64 wait_ms)
Waits on the thread work to complete. Blocks until work is complete. This includes a timeout,...
u32(* pfn_thread_start)(void *)
Definition: kthread.h:18
KAPI void kthread_detach(kthread *thread)
KAPI b8 kthread_create(pfn_thread_start start_function_ptr, void *params, b8 auto_detach, kthread *out_thread)
KAPI b8 kthread_wait(kthread *thread)
Waits on the thread work to complete. Blocks until work is complete.
KAPI b8 kthread_is_active(kthread *thread)
struct kthread kthread
KAPI void kthread_cancel(kthread *thread)
KAPI u64 platform_current_thread_id(void)
Obtains the identifier for the current thread.
A simple queue container. Elements are popped off the queue in the same order they were pushed to it.
Definition: kthread.h:11
u64 thread_id
Definition: kthread.h:13
void * internal_data
Definition: kthread.h:12
queue work_queue
Definition: kthread.h:14
A simple queue container. Elements are popped off the queue in the same order they were pushed to it.
Definition: queue.h:21