OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Ogre::Threads Class Reference

#include <OgreThreads.h>

Static Public Member Functions

static ThreadHandlePtr CreateThread (THREAD_ENTRY_POINT entryPoint, size_t threadIdx, void *param)
 Creates and executes a new thread. More...
 
static void WaitForThreads (size_t numThreadHandles, const ThreadHandlePtr *threadHandles)
 Waits until all threads are finished. More...
 
static void WaitForThreads (const ThreadHandleVec &threadHandles)
 

Detailed Description

Definition at line 129 of file OgreThreads.h.

Member Function Documentation

static ThreadHandlePtr Ogre::Threads::CreateThread ( THREAD_ENTRY_POINT  entryPoint,
size_t  threadIdx,
void *  param 
)
static

Creates and executes a new thread.

Remarks
The function to execute must be declared via THREAD_DECLARE, and the first argument must be provided through THREAD_GET. The following example shows how to use:

unsigned long myOwnThread( ThreadHandle *ownThreadHandle ) { Should print "Hello from thread 50" printf( "Hello from thread %i", ownThreadHandle.getThreadIdx() ); return 0; } THREAD_DECLARE( myOwnThread );

int main() { ThreadHandle handle = CreateThread( THREAD_GET( myOwnThread ), 50, 0 ); WaitForThreads( 1, handle ); return 0; }

It is not possible to retrieve the return value of the function because it's not portable (and trying to emulate it induces to easy-to-cause memory leaks; as we're dealing with C functions + potential race conditions, not C++)

Parameters
entryPointFunction name of the entry point. VERY IMPORTANT: The entry point must be provided by THREAD_GET. Do not use a function directly, otherwise there will be memory leaks!
threadIdxOptional index for this thread (ie. when you have many worker threads to work on a section of data.
paramOptional argument to be passed.
Returns
Handle to created thread.
static void Ogre::Threads::WaitForThreads ( size_t  numThreadHandles,
const ThreadHandlePtr threadHandles 
)
static

Waits until all threads are finished.

Parameters
numThreadInfosNumber of ThreadHandle passed in the array as 'threadHandles'
threadHandlesArray of numThreadHandles or more ThreadHandle
Remarks
Don't pass more than 128 handles per call
static void Ogre::Threads::WaitForThreads ( const ThreadHandleVec threadHandles)
static

The documentation for this class was generated from the following file: