fix race between StaticMetaBase::destroy() and StaticMetaBase::onThreadExit()
Summary:
We would like to guarantee that after `folly::ThreadLocal<>` dtor
returns no per-thread instances are longer alive. Currently this is not a case:
* T1 is excuting `StaticMetaBase::onThreadExit()`, it acquired all per-thread
instances and erased them from meta under `accessAllThreadsLock_`.
* T2 destroys `folly::ThreadLocal<>`, it executes `StaticMetaBase::destroy()`,
collects all per-thread instances (thus missing the ones being destroyed by
T1), destroys them and returns.
* T1 executes dtor of per-thread instances, after parent `folly::ThreadLocal<>`
dtor is finished.
Reviewed By: ot
Differential Revision:
D4109820
fbshipit-source-id:
d547b8cc77c9871126538c38644c2e98ddccf220