Implementation of platform-agnostic CPU threads. More...
Macros | |
#define | AI_MAX_THREADS 1024 |
maximum number of threads | |
Functions | |
AI_API void * | AiThreadCreate (unsigned int(*fn)(void *), void *data, int priority) |
Creates a thread and returns a handler for the thread. More... | |
AI_API void | AiThreadClose (void *thread) |
Closes thread handle, to avoid resource leaks. More... | |
AI_API void | AiThreadWait (void *thread) |
Wait for a thread to finish. More... | |
AI_API AI_CONST void * | AiThreadSelf () |
Returns a handle for the current (calling) thread. More... | |
Implementation of platform-agnostic CPU threads.
AI_API void * AiThreadCreate | ( | unsigned int(*)(void *) | fn, |
void * | data, | ||
int | priority | ||
) |
Creates a thread and returns a handler for the thread.
After the thread is finished, a pairing call to AiThreadClose() is needed to avoid resource leaks.
The thread priority is valid only for Windows. For example, a render manager that takes advantage of unused background CPU cycles in an artist's workstation would probably want to use lowest priority threads so that other applications can run smoothly.
fn | pointer to the function the new thread will execute |
data | data pointer for new thread |
priority | priority of thread, e.g. AI_PRIORITY_LOW , etc; has no effect on Linux and OS X |
AI_API void AiThreadClose | ( | void * | thread | ) |
Closes thread handle, to avoid resource leaks.
The thread is effectively destroyed so the handle can't be used anymore.
thread | thread handle |
AI_API void AiThreadWait | ( | void * | thread | ) |
Wait for a thread to finish.
This function will not return until the thread finishes executing its user-supplied function. The thread handle must point to an existing thread that has not been destroyed with AiThreadClose(), otherwise the behaviour is undefined.
thread | thread handle |
AI_API void * AiThreadSelf | ( | ) |