20 #if !defined(__MITSUBA_CORE_TLS_H_)
21 #define __MITSUBA_CORE_TLS_H_
23 #include <mitsuba/mitsuba.h>
24 #include <boost/scoped_ptr.hpp>
40 typedef void *(*ConstructFunctor)();
42 typedef void (*DestructFunctor)(
void *);
44 ThreadLocalBase(
const ConstructFunctor &constructFunctor,
45 const DestructFunctor &destructFfunctor);
51 const void *
get()
const;
53 void *
get(
bool &existed);
55 const void *
get(
bool &existed)
const;
57 struct ThreadLocalPrivate;
58 mutable boost::scoped_ptr<ThreadLocalPrivate> d;
90 inline const ValueType *
get()
const {
return ((
const ref<ValueType> *) m_base.get())->
get(); }
122 inline void set(ValueType &value) {
127 inline ValueType &
get() {
128 return *((ValueType *) m_base.get());
135 inline const ValueType &
get()
const {
136 return *((
const ValueType *) m_base.get());
140 return new ValueType();
145 delete static_cast<ValueType *
>(data);
void set(ValueType *ptr)
Update the data associated with the current thread.
Definition: tls.h:81
static void destruct(void *data)
Definition: tls.h:143
static void * construct()
Definition: tls.h:92
detail::ThreadLocalBase m_base
Definition: tls.h:100
#define MTS_EXPORT_CORE
Definition: getopt.h:29
ThreadLocal()
Construct a new thread local storage object.
Definition: tls.h:78
detail::ThreadLocalBase m_base
Definition: tls.h:148
static void destruct(void *data)
Definition: tls.h:96
Reference counting helper.
Definition: ref.h:40
Thin wrapper around posix thread local storage. Stores heap-allocated data other than Object instance...
Definition: tls.h:115
PrimitiveThreadLocal()
Construct a new thread local storage object.
Definition: tls.h:118
void set(ValueType &value)
Update the data associated with the current thread.
Definition: tls.h:122
static void * construct()
Definition: tls.h:139