diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2012-09-01 10:04:05 -0700 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2012-09-01 10:27:52 -0700 |
commit | 4a893f72cadaa875a920db8949171b002f656e43 (patch) | |
tree | 1e08a3cb6f579cab9c3c9a138d36ababdf76121b /src/Local.cc | |
parent | 56d91ddd2cd42b782cde0bb3fdf4eb9ebe7597be (diff) | |
parent | 06674e57649d536cf19715524ee40c5ad4a9026d (diff) |
Merge commit '06674e57649d536cf19715524ee40c5ad4a9026d'
Conflicts:
includes/LuaTask.h
includes/TaskMan.h
includes/Threads.h
src/TaskMan.cc
src/Threads.cc
Diffstat (limited to 'src/Local.cc')
-rw-r--r-- | src/Local.cc | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/Local.cc b/src/Local.cc index 9729c35..a9eccdd 100644 --- a/src/Local.cc +++ b/src/Local.cc @@ -13,10 +13,6 @@ void * Balau::TLSManager::setTLS(void * val) { return r; } -void * Balau::TLSManager::createTLS() { - return Local::create(); -} - static Balau::TLSManager dummyTLSManager; Balau::TLSManager * Balau::g_tlsManager = &dummyTLSManager; @@ -29,31 +25,31 @@ void Balau::Local::doStart() { m_globals[m_idx] = 0; } -class PThreadsTLSManager : public Balau::TLSManager, public Balau::AtStart { +class GlobalPThreadsTLSManager : public Balau::PThreadsTLSManager, public Balau::AtStart { public: - PThreadsTLSManager() : AtStart(0) { } - virtual void * getTLS(); - virtual void * setTLS(void * val); - virtual void doStart(); - private: - pthread_key_t m_key; + GlobalPThreadsTLSManager() : AtStart(0) { } + void doStart(); }; -PThreadsTLSManager pthreadsTLSManager; +GlobalPThreadsTLSManager pthreadsTLSManager; + +void GlobalPThreadsTLSManager::doStart() { + init(); + Balau::g_tlsManager = this; +} -void PThreadsTLSManager::doStart() { +void Balau::PThreadsTLSManager::init() { int r; r = pthread_key_create(&m_key, NULL); RAssert(r == 0, "Unable to create a pthtread_key: %i", r); - Balau::g_tlsManager = this; } -void * PThreadsTLSManager::getTLS() { +void * Balau::PThreadsTLSManager::getTLS() { return pthread_getspecific(m_key); } -void * PThreadsTLSManager::setTLS(void * val) { +void * Balau::PThreadsTLSManager::setTLS(void * val) { void * r = pthread_getspecific(m_key); pthread_setspecific(m_key, val); return r; |