Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::Thread Class Referenceabstract

Cross-platform thread implementation. More...

#include <mitsuba/mitsuba.h>

+ Inheritance diagram for mitsuba::Thread:

Public Types

enum  EThreadPriority {
  EIdlePriority = 0, ELowestPriority, ELowPriority, ENormalPriority,
  EHighPriority, EHighestPriority, ERealtimePriority
}
 Possible priority values for Thread::setPriority() More...
 

Public Member Functions

 Thread (const std::string &name)
 Create a new thread object. More...
 
bool setPriority (EThreadPriority priority)
 Set the thread priority. More...
 
EThreadPriority getPriority () const
 Return the thread priority. More...
 
void setCoreAffinity (int core)
 Set the core affinity. More...
 
int getCoreAffinity () const
 Return the core affinity. More...
 
void setCritical (bool critical)
 Specify whether or not this thread is critical. More...
 
bool getCritical () const
 Return the value of the critical flag. More...
 
const std::string & getName () const
 Return the name of this thread. More...
 
void setName (const std::string &name)
 Set the name of this thread. More...
 
ThreadgetParent ()
 Return the parent thread. More...
 
const ThreadgetParent () const
 Return the parent thread (const version) More...
 
void setLogger (Logger *logger)
 Set the logger instance used to process log messages from this thread. More...
 
LoggergetLogger ()
 Return the thread's logger instance. More...
 
void setFileResolver (FileResolver *fresolver)
 Set the thread's file resolver. More...
 
FileResolvergetFileResolver ()
 Return the thread's file resolver. More...
 
bool isRunning () const
 Is this thread still running? More...
 
void start ()
 Start the thread. More...
 
void detach ()
 Detach the thread and release resources. More...
 
void join ()
 Wait until the thread finishes. More...
 
virtual std::string toString () const
 Return a string representation. More...
 
virtual const ClassgetClass () const
 Retrieve this object's class. More...
 
- Public Member Functions inherited from Object
 Object ()
 Construct a new object. More...
 
int getRefCount () const
 Return the current reference count. More...
 
void incRef () const
 Increase the reference count of the object by one. More...
 
void decRef (bool autoDeallocate=true) const
 Decrease the reference count of the object and possibly deallocate it. More...
 

Static Public Member Functions

static int getID ()
 Return the thread ID. More...
 
static ThreadgetThread ()
 Return the current thread. More...
 
static void sleep (unsigned int ms)
 Sleep for a certain amount of time. More...
 
static void staticInitialization ()
 Initialize the threading system. More...
 
static void staticShutdown ()
 Shut down the threading system. More...
 
static void initializeOpenMP (size_t threadCount)
 Initialize Mitsuba's threading system for simultaneous use of OpenMP. More...
 
static ThreadregisterUnmanagedThread (const std::string &name)
 Register an unmanaged thread with Mitsuba (i.e. one that doesn't derive from mitsuba::Thread) More...
 
static void registerCrashHandler (bool(*handler)(void))
 Register a thread crash handler. More...
 
- Static Public Member Functions inherited from Object
static void staticInitialization ()
 Initializes the built-in reference count debugger (if enabled) More...
 
static void staticShutdown ()
 Free the memory taken by staticInitialization() More...
 

Static Public Attributes

static Classm_theClass
 
- Static Public Attributes inherited from Object
static Classm_theClass
 Pointer to the object's class descriptor. More...
 

Protected Member Functions

virtual ~Thread ()
 Virtual destructor. More...
 
void exit ()
 
void yield ()
 Yield to another processor. More...
 
virtual void run ()=0
 The thread's run method. More...
 
- Protected Member Functions inherited from Object
virtual ~Object ()
 Virtual private deconstructor. (Will only be called by ref) More...
 

Static Protected Member Functions

static void dispatch (Thread *thread)
 Thread dispatch function. More...
 

Detailed Description

Cross-platform thread implementation.

Member Enumeration Documentation

Possible priority values for Thread::setPriority()

Enumerator
EIdlePriority 
ELowestPriority 
ELowPriority 
ENormalPriority 
EHighPriority 
EHighestPriority 
ERealtimePriority 

Constructor & Destructor Documentation

mitsuba::Thread::Thread ( const std::string &  name)

Create a new thread object.

Parameters
nameAn identifying name of this thread (will be shown in debug messages)
Remarks
Note that it is currently not possible to construct Thread instances from Python
virtual mitsuba::Thread::~Thread ( )
protectedvirtual

Virtual destructor.

Member Function Documentation

void mitsuba::Thread::detach ( )

Detach the thread and release resources.

After a call to this function, join() cannot be used anymore. This releases resources, which would otherwise be held until a call to join().

static void mitsuba::Thread::dispatch ( Thread thread)
staticprotected

Thread dispatch function.

void mitsuba::Thread::exit ( )
protected

Exit the thread, should be called from inside the thread

virtual const Class* mitsuba::Thread::getClass ( ) const
virtual
int mitsuba::Thread::getCoreAffinity ( ) const

Return the core affinity.

bool mitsuba::Thread::getCritical ( ) const

Return the value of the critical flag.

FileResolver* mitsuba::Thread::getFileResolver ( )

Return the thread's file resolver.

static int mitsuba::Thread::getID ( )
static

Return the thread ID.

Logger* mitsuba::Thread::getLogger ( )

Return the thread's logger instance.

const std::string& mitsuba::Thread::getName ( ) const

Return the name of this thread.

Thread* mitsuba::Thread::getParent ( )

Return the parent thread.

const Thread* mitsuba::Thread::getParent ( ) const

Return the parent thread (const version)

EThreadPriority mitsuba::Thread::getPriority ( ) const

Return the thread priority.

static Thread* mitsuba::Thread::getThread ( )
static

Return the current thread.

static void mitsuba::Thread::initializeOpenMP ( size_t  threadCount)
static

Initialize Mitsuba's threading system for simultaneous use of OpenMP.

bool mitsuba::Thread::isRunning ( ) const

Is this thread still running?

void mitsuba::Thread::join ( )

Wait until the thread finishes.

static void mitsuba::Thread::registerCrashHandler ( bool(*)(void)  handler)
static

Register a thread crash handler.

A crash handler is called whenever a thread fails with an uncaught exception. This can be used to implement more useful error messages in certain circumstances

static Thread* mitsuba::Thread::registerUnmanagedThread ( const std::string &  name)
static

Register an unmanaged thread with Mitsuba (i.e. one that doesn't derive from mitsuba::Thread)

Should be called from the thread in question. The function returns a Mitsuba handle to the thread

void mitsuba::Thread::setCoreAffinity ( int  core)

Set the core affinity.

This function provides a hint to the operating system scheduler that the thread should preferably run on the specified processor core. By default, the parameter is set to -1, which means that there is no affinity.

void mitsuba::Thread::setCritical ( bool  critical)

Specify whether or not this thread is critical.

When an thread marked critical crashes from an uncaught exception, the whole process is brought down. The default is false.

void mitsuba::Thread::setFileResolver ( FileResolver fresolver)

Set the thread's file resolver.

void mitsuba::Thread::setLogger ( Logger logger)

Set the logger instance used to process log messages from this thread.

void mitsuba::Thread::setName ( const std::string &  name)

Set the name of this thread.

bool mitsuba::Thread::setPriority ( EThreadPriority  priority)

Set the thread priority.

This does not always work – for instance, Linux requires root privileges for this operation.

Returns
true upon success.
static void mitsuba::Thread::sleep ( unsigned int  ms)
static

Sleep for a certain amount of time.

void mitsuba::Thread::start ( )

Start the thread.

static void mitsuba::Thread::staticInitialization ( )
static

Initialize the threading system.

static void mitsuba::Thread::staticShutdown ( )
static

Shut down the threading system.

virtual std::string mitsuba::Thread::toString ( ) const
virtual

Return a string representation.

Reimplemented from Object.

void mitsuba::Thread::yield ( )
protected

Yield to another processor.

Member Data Documentation

Class* mitsuba::Thread::m_theClass
static

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