20 #if !defined(__MITSUBA_CORE_THREAD_H_)
21 #define __MITSUBA_CORE_THREAD_H_
23 #include <mitsuba/mitsuba.h>
24 #include <boost/scoped_ptr.hpp>
54 Thread(
const std::string &name);
64 bool setPriority(EThreadPriority priority);
67 EThreadPriority getPriority()
const;
77 void setCoreAffinity(
int core);
80 int getCoreAffinity()
const;
89 void setCritical(
bool critical);
92 bool getCritical()
const;
98 const std::string &getName()
const;
101 void setName(
const std::string &name);
107 const Thread *getParent()
const;
110 void setLogger(
Logger *logger);
122 static Thread *getThread();
125 bool isRunning()
const;
143 virtual std::string
toString()
const;
146 static void sleep(
unsigned int ms);
155 static void initializeOpenMP(
size_t threadCount);
164 static Thread *registerUnmanagedThread(
const std::string &name);
173 static void registerCrashHandler(
bool (*handler)(
void));
181 static
void dispatch(Thread *thread);
193 virtual
void run() = 0;
195 struct ThreadPrivate;
196 boost::scoped_ptr<ThreadPrivate> d;
199 #if defined(MTS_OPENMP)
207 #define mts_omp_get_max_threads omp_get_max_threads
208 #define mts_omp_get_thread_num omp_get_thread_num
211 #define mts_omp_get_max_threads() 1
212 #define mts_omp_get_thread_num() 0
static void staticInitialization()
Initializes the built-in reference count debugger (if enabled)
#define MTS_EXPORT_CORE
Definition: getopt.h:29
File resolution helper.
Definition: fresolver.h:41
#define mts_omp_get_max_threads()
Definition: thread.h:211
EThreadPriority
Possible priority values for Thread::setPriority()
Definition: thread.h:37
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition: class.h:158
Cross-platform thread implementation.
Definition: thread.h:34
#define mts_omp_get_thread_num()
Definition: thread.h:212
Responsible for processing log messages.
Definition: logger.h:116
Parent of all Mitsuba classes.
Definition: object.h:38
virtual std::string toString() const
Return a human-readable string representation of the object's contents.
static void staticShutdown()
Free the memory taken by staticInitialization()