summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2012-08-31 16:13:04 -0700
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2012-08-31 16:13:04 -0700
commitd2db92f6b5d275b3150deb7a52a8da142a7cc953 (patch)
treedc321491b6a9b54d6e8b6477fddf384f2e5ce7ec /includes
parent7866096c62f265960d48a61ceb1ad8d53e44400a (diff)
Simplifying TLS code a bit (removing createTLS...) and making the PthreadsTLSManager its own global class.
Diffstat (limited to 'includes')
-rw-r--r--includes/Local.h12
1 files changed, 10 insertions, 2 deletions
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();