From a879b58a1f3c30bac5c4174fc6f511f2b8fadf62 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 15 Aug 2012 18:07:41 +0000 Subject: Remove unnecessary Jack thread bookkeeping stuff. git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4703 a436a847-0d15-0410-975c-d299462d15a1 --- raul/ThreadVar.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'raul') diff --git a/raul/ThreadVar.hpp b/raul/ThreadVar.hpp index fde3f81..f786f9c 100644 --- a/raul/ThreadVar.hpp +++ b/raul/ThreadVar.hpp @@ -17,16 +17,18 @@ #ifndef RAUL_THREADVAR_HPP #define RAUL_THREADVAR_HPP +#include "raul/Noncopyable.hpp" + #include namespace Raul { -struct ThreadVarImpl; - /** Thread-specific variable. + * + * A ThreadVar is a variable which has a different value for each thread. */ template -class ThreadVar +class ThreadVar : public Noncopyable { public: ThreadVar(const T& default_value) @@ -39,6 +41,7 @@ public: pthread_key_delete(_key); } + /** Set the value for the calling thread. */ ThreadVar& operator=(const T& value) { T* val = (T*)pthread_getspecific(_key); if (val) { @@ -50,15 +53,13 @@ public: return *this; } + /** Get the value for the calling thread. */ operator T() const { T* val = (T*)pthread_getspecific(_key); return val ? *val : _default_value; } private: - ThreadVar(const ThreadVar& noncopyable); - ThreadVar& operator=(const ThreadVar& noncopyable); - static void destroy_value(void* ptr) { delete (T*)ptr; } -- cgit v1.2.1