From d2db92f6b5d275b3150deb7a52a8da142a7cc953 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Fri, 31 Aug 2012 16:13:04 -0700 Subject: Simplifying TLS code a bit (removing createTLS...) and making the PthreadsTLSManager its own global class. --- includes/Local.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'includes') diff --git a/includes/Local.h b/includes/Local.h index 6a598ab..9221384 100644 --- a/includes/Local.h +++ b/includes/Local.h @@ -8,7 +8,15 @@ class TLSManager { public: virtual void * getTLS(); virtual void * setTLS(void * val); - void * createTLS(); +}; + +class PThreadsTLSManager : public TLSManager { + public: + virtual void * getTLS(); + virtual void * setTLS(void * val); + void init(); + private: + pthread_key_t m_key; }; extern TLSManager * g_tlsManager; @@ -16,6 +24,7 @@ extern TLSManager * g_tlsManager; class Local : public AtStart { public: static int getSize() { return s_size; } + static void * createTLS() { void * r = calloc(s_size * sizeof(void *), 1); return r; } protected: Local() : AtStart(0) { } void * getGlobal() { return m_globals[m_idx]; } @@ -26,7 +35,6 @@ class Local : public AtStart { void set(void * obj) { void * r = getTLS(); if (r) setLocal(obj); else setGlobal(obj); } int getIndex() { return m_idx; } private: - static void * create() { void * r = calloc(s_size * sizeof(void *), 1); return r; } static void * getTLS() { return g_tlsManager->getTLS(); } static void * setTLS(void * val) { return g_tlsManager->setTLS(val); } virtual void doStart(); -- cgit v1.2.3