Making each SingletonEntry a singleton
authorAndrii Grynenko <andrii@fb.com>
Wed, 4 Feb 2015 17:48:12 +0000 (09:48 -0800)
committerSara Golemon <sgolemon@fb.com>
Wed, 11 Feb 2015 02:02:00 +0000 (18:02 -0800)
commit8f7c257f327879b2cf824007958e33bd35347de4
treedd3cc3f9a17a3e375eeea68f2f094a4cd83ce0f1
parenta11dc9b7dfda07a11b702ef27578feb391caf811
Making each SingletonEntry a singleton

Summary:
Most of the singleton construction logic is moved to SingletonEntry, and each SingletonEntry is now also a singleton.
SingletonVault becomes only responsible for keeping singleton construction order (and potentially dependencies) and destoying them in correct order.
This also significantly improves perf of get() / get_weak() (not-fast)

This diff is based on D1823663.

Test Plan:
unit test

============================================================================
folly/experimental/test/SingletonTest.cpp       relative  time/iter  iters/s
============================================================================
NormalSingleton                                            333.35ps    3.00G
MeyersSingleton                                   99.99%   333.39ps    3.00G
FollySingletonSlow                                49.99%   666.84ps    1.50G
FollySingletonFast                                95.90%   347.61ps    2.88G
FollySingletonFastWeak                             2.22%    15.00ns   66.66M
============================================================================

Reviewed By: chip@fb.com

Subscribers: trunkagent, folly-diffs@, yfeldblum

FB internal diff: D1827390

Signature: t1:1827390:1423268514:da322d1dcaba54905d478b253f26dd76f890fb4e
folly/Makefile.am
folly/experimental/Singleton-inl.h [new file with mode: 0644]
folly/experimental/Singleton.cpp
folly/experimental/Singleton.h