diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2011-03-23 22:53:44 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2011-03-23 22:53:44 -0400 |
commit | 918ed4bf919a55e3eb5d99d98c9b915921dc11ab (patch) | |
tree | a5739e7aa6444762a21f2b15ab9d633ec5059b49 /utils/threadlocal.h | |
parent | 57a218e86e30d57d9795bccd280737c431f6b4e4 (diff) |
remove thread-local stuff which was fragile on some build systems
Diffstat (limited to 'utils/threadlocal.h')
-rwxr-xr-x | utils/threadlocal.h | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/utils/threadlocal.h b/utils/threadlocal.h deleted file mode 100755 index d79f5d9d..00000000 --- a/utils/threadlocal.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef THREADLOCAL_H -#define THREADLOCAL_H - -#ifndef SETLOCAL_SWAP -# define SETLOCAL_SWAP 0 -#endif - -#ifdef BOOST_NO_MT - -# define THREADLOCAL - -#else - -#ifdef _MSC_VER - -//FIXME: doesn't work with DLLs ... use TLS apis instead (http://www.boost.org/libs/thread/doc/tss.html) -# define THREADLOCAL __declspec(thread) - -#else - -# define THREADLOCAL __thread - -#endif - -#endif - -#include <algorithm> //swap - -// naturally, the below are only thread-safe if value is THREADLOCAL -template <class D> -struct SaveLocal { - D &value; - D old_value; - SaveLocal(D& val) : value(val), old_value(val) {} - ~SaveLocal() { -#if SETLOCAL_SWAP - swap(value,old_value); -#else - value=old_value; -#endif - } -}; - -template <class D> -struct SetLocal { - D &value; - D old_value; - SetLocal(D& val,const D &new_value) : value(val), old_value( -#if SETLOCAL_SWAP - new_value -#else - val -#endif - ) { -#if SETLOCAL_SWAP - swap(value,old_value); -#else - value=new_value; -#endif - } - ~SetLocal() { -#if SETLOCAL_SWAP - swap(value,old_value); -#else - value=old_value; -#endif - } -}; - - -#endif |