Try again: folly::Singleton, a class for managing singletons
authorChip Turner <chip@fb.com>
Fri, 23 May 2014 03:17:14 +0000 (20:17 -0700)
committerChip Turner <chip@fb.com>
Fri, 25 Jul 2014 16:07:19 +0000 (09:07 -0700)
commit2fcb96be06a8c657e2b17760fbe55d8800a98e01
tree6dcba53bcf2efa5f4190368903e8c9afb16a38b2
parent1e5e33a557fc1f2b7f1322b928566fe71bcf26ad
Try again: folly::Singleton, a class for managing singletons

Summary:
Singletons are surprisingly tricky in a codebase where
libraries depend on one another.  folly::Singleton hopes to make this
process more reliable by ensuring object creation happens in a safe
order, that destruction is possible, and that singletons are created
on-demand.

The basic fbcode use intention is to invoke registration completion in
initFacebook, so users need only declare singletons via
Singleton<ClassName> in their .cpp files.

This diff ties the Singletons into the core Init process, but not hhvm
(which will be a separate diff).

Test Plan: runtests

Reviewed By: joelm@fb.com, hans@fb.com

Subscribers: fbcode-common-diffs@, hphp-diffs@, soren, anca, lins, aalexandre, ps, trunkagent, lucian, hannesr, yfeldblum, maxwellsayles

FB internal diff: D1453135
folly/Exception.h
folly/experimental/Singleton.cpp [new file with mode: 0644]
folly/experimental/Singleton.h [new file with mode: 0644]
folly/experimental/test/SingletonTest.cpp [new file with mode: 0644]