X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FSystem%2FThreadLocal.h;fp=include%2Fllvm%2FSystem%2FThreadLocal.h;h=3d44f62e959323051a94fa418ded88ae2362ce91;hb=e850e6e162064232d06a3638112fb7d000b27bc4;hp=39b1e64be0cdb2c5fa0085d9010f4d1b8502b8e6;hpb=9da5c997c0015079c9f082759ea07ea09f285333;p=oota-llvm.git diff --git a/include/llvm/System/ThreadLocal.h b/include/llvm/System/ThreadLocal.h index 39b1e64be0c..3d44f62e959 100644 --- a/include/llvm/System/ThreadLocal.h +++ b/include/llvm/System/ThreadLocal.h @@ -19,6 +19,8 @@ namespace llvm { namespace sys { + // ThreadLocalImpl - Common base class of all ThreadLocal instantiations. + // YOU SHOULD NEVER USE THIS DIRECTLY. class ThreadLocalImpl { void* data; public: @@ -28,11 +30,18 @@ namespace llvm { const void* getInstance(); }; + /// ThreadLocal - A class used to abstract thread-local storage. It holds, + /// for each thread, a pointer a single object of type T. template class ThreadLocal : public ThreadLocalImpl { public: ThreadLocal() : ThreadLocalImpl() { } + + /// get - Fetches a pointer to the object associated with the current + /// thread. If no object has yet been associated, it returns NULL; T* get() { return static_cast(getInstance()); } + + // set - Associates a pointer to an object with the current thread. void set(T* d) { setInstance(d); } }; }