From 58c61d29598539000553920c3640333af519d8a8 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sun, 27 Jan 2013 18:02:22 -0500 Subject: [PATCH] put back some comments --- src/libcore/tls.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libcore/tls.cpp b/src/libcore/tls.cpp index 34328ee9..75f6912b 100644 --- a/src/libcore/tls.cpp +++ b/src/libcore/tls.cpp @@ -133,22 +133,24 @@ struct ThreadLocalBase::ThreadLocalPrivate { /// Look up a TLS entry. The goal is to make this operation very fast! std::pair get() { bool existed = true; + void *data; #if defined(__OSX__) PerThreadData *ptd = (PerThreadData *) pthread_getspecific(ptdLocal); #else PerThreadData *ptd = ptdLocal; #endif - if(EXPECT_NOT_TAKEN(!ptd)) { - throw std::runtime_error("null per-thread data"); - } + if (EXPECT_NOT_TAKEN(!ptd)) + throw std::runtime_error("Internal error: call to ThreadLocalPrivate::get() " + " precedes the construction of thread-specific data structures!"); - void *data; + /* This is an uncontended thread-local lock (i.e. not to worry) */ boost::lock_guard guard(ptd->mutex); PerThreadData::key_iterator it = ptd->map.find(this); if (EXPECT_TAKEN(it != ptd->map.end())) { data = it->second.data; } else { + /* This is the first access from this thread */ TLSEntry entry; entry.data = data = constructFunctor(); entry.destructFunctor = destructFunctor;