Macros | Functions
Thread Management API

Implementation of platform-agnostic CPU threads. More...

Macros

#define AI_MAX_THREADS   256
 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...
 

Thread Priorities

#define AI_PRIORITY_LOWEST   0x00
 even lower priority than AI_PRIORITY_LOW
 
#define AI_PRIORITY_LOW   0x01
 low thread priority
 
#define AI_PRIORITY_NORMAL   0x02
 normal thread priority
 
#define AI_PRIORITY_HIGH   0x03
 high thread priority
 

Detailed Description

Implementation of platform-agnostic CPU threads.

Function Documentation

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.

Parameters
fnpointer to the function the new thread will execute
datadata pointer for new thread
prioritypriority of thread, e.g. AI_PRIORITY_LOW, etc; has no effect on Linux and OS X
Returns
thread handle of the newly created thread
See also
AiThreadClose, AiThreadWait, AiThreadSelf
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.

Parameters
threadthread handle
See also
AiThreadCreate
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.

Parameters
threadthread handle
See also
AiThreadCreate, AiThreadClose
AI_API void * AiThreadSelf ( )

Returns a handle for the current (calling) thread.

Returns
thread handle
See also
AiThreadCreate

© 2020 Autodesk, Inc. · All rights reserved · www.arnoldrenderer.com