Skip to content

cf_thread_create

Category: multithreading
GitHub: cute_multithreading.h


Creates a new thread and runs it's thread function (CF_ThreadFn).

CF_Thread* cf_thread_create(CF_ThreadFn func, const char* name, void* udata);
Parameters Description
func The function to run for the thread.
name The name of this thread. Must be unique.
udata Can be NULL. This gets handed back to you in your func.

Return Value

Returns an opaque pointer to CF_Thread.

Code Example

Example syntax of a thread.

int MyThreadFn(void udata)
{
    // Do work here...
    return 0;
}

Remarks

Unless you call cf_thread_detach you should call cf_thread_wait from another thread to clean up resources and get the thread's return value back. It is considered a leak otherwise.

CF_Thread
CF_ThreadFn
cf_thread_wait
cf_thread_detach
cf_thread_get_id
cf_thread_id