put back some comments
parent
82255028d6
commit
58c61d2959
|
@ -133,22 +133,24 @@ struct ThreadLocalBase::ThreadLocalPrivate {
|
||||||
/// Look up a TLS entry. The goal is to make this operation very fast!
|
/// Look up a TLS entry. The goal is to make this operation very fast!
|
||||||
std::pair<void *, bool> get() {
|
std::pair<void *, bool> get() {
|
||||||
bool existed = true;
|
bool existed = true;
|
||||||
|
void *data;
|
||||||
|
|
||||||
#if defined(__OSX__)
|
#if defined(__OSX__)
|
||||||
PerThreadData *ptd = (PerThreadData *) pthread_getspecific(ptdLocal);
|
PerThreadData *ptd = (PerThreadData *) pthread_getspecific(ptdLocal);
|
||||||
#else
|
#else
|
||||||
PerThreadData *ptd = ptdLocal;
|
PerThreadData *ptd = ptdLocal;
|
||||||
#endif
|
#endif
|
||||||
if(EXPECT_NOT_TAKEN(!ptd)) {
|
if (EXPECT_NOT_TAKEN(!ptd))
|
||||||
throw std::runtime_error("null per-thread data");
|
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<boost::recursive_mutex> guard(ptd->mutex);
|
boost::lock_guard<boost::recursive_mutex> guard(ptd->mutex);
|
||||||
PerThreadData::key_iterator it = ptd->map.find(this);
|
PerThreadData::key_iterator it = ptd->map.find(this);
|
||||||
if (EXPECT_TAKEN(it != ptd->map.end())) {
|
if (EXPECT_TAKEN(it != ptd->map.end())) {
|
||||||
data = it->second.data;
|
data = it->second.data;
|
||||||
} else {
|
} else {
|
||||||
|
/* This is the first access from this thread */
|
||||||
TLSEntry entry;
|
TLSEntry entry;
|
||||||
entry.data = data = constructFunctor();
|
entry.data = data = constructFunctor();
|
||||||
entry.destructFunctor = destructFunctor;
|
entry.destructFunctor = destructFunctor;
|
||||||
|
|
Loading…
Reference in New Issue