Don't throw in Singleton::get() if singleton is alive
authorAndrii Grynenko <andrii@fb.com>
Thu, 16 Oct 2014 00:40:15 +0000 (17:40 -0700)
committerdcsommer <dcsommer@fb.com>
Fri, 17 Oct 2014 18:44:20 +0000 (11:44 -0700)
commitfa0c6eaec475677ae49bffd00f692658aca67acd
treee4943f9999326fd0b99b977cf6132dde2bd81fbf
parenta4eda9d3a960b35fbf1d5a3d4ac028a604637313
Don't throw in Singleton::get() if singleton is alive

Summary:
This is a fix for situations where you know that something is keeping singleton alive (by getting a weak_ptr and locking it), and request a singleton instance via get() method (if e.g. it's hard to pass a pointer to singleton instance from a method which locked it). If shutdown was scheduled - an exception was previously thrown even though the object was not destroyed yet.

This simplifies conversion of legacy code to folly::Singleton.

Test Plan:
fbconfig -r gatehouse/usersets/tests
fbmake runtests

Reviewed By: chip@fb.com

Subscribers: trunkagent, njormrod

FB internal diff: D1619311
folly/experimental/Singleton.h