Fix bug in circular singleton creation detection
Summary:
We considered it circular if we tried to create a singleton
while the singleton was being created. In a single threaded world, this
is correct, but under concurrency, two threads can be in the singleton
creation codepath and become confused about the state of the singleton.
This change uses a condition variable to notify when creation completes
so that other threads can wait on the creation to complete. Circular
creation is detected via thread id.
Test Plan:
runtests (new test case; failed without the fix, passes with
it)
Reviewed By: hans@fb.com
Subscribers: lins, anca, njormrod, rkroll
FB internal diff:
D1534081