folly Singleton: clear some state if creator function fails
authorSteve O'Brien <steveo@fb.com>
Sun, 19 Jul 2015 16:22:34 +0000 (09:22 -0700)
committerSara Golemon <sgolemon@fb.com>
Mon, 20 Jul 2015 19:26:32 +0000 (12:26 -0700)
commitad7e7f72235d3803b0077c7acbd082c79eb99709
tree010bce79753dc2d71dae49e2b94d452f6757c409
parent8a8767014e221e18c4023c2864918db4e84435cd
folly Singleton: clear some state if creator function fails

Summary: The creator thread ID is saved to indicate the singleton is already being built (to help detect dependency cycles).  However if the creation function throws an error, that thread ID persists, and then if the same thread tries again to build the singleton it will be falsely detected as a dependency cycle.  This clears that state in the case of failure.

Reviewed By: @chipturner

Differential Revision: D2256441
folly/Singleton-inl.h
folly/test/SingletonTest.cpp