X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FSingleton.h;h=c8cbea9f56fd09f38b0edf525824ef9b36717e80;hb=c9cbfdb7254cef993316a53e8ad11e8cf1c6f33f;hp=c377f3ad02c49c6b3cc2a6f233d7c80371edb15c;hpb=0416e1ea440f816d5543feb5e834f09906ddfcab;p=folly.git diff --git a/folly/Singleton.h b/folly/Singleton.h index c377f3ad..c8cbea9f 100644 --- a/folly/Singleton.h +++ b/folly/Singleton.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -348,7 +348,7 @@ class SingletonVault { } }; - explicit SingletonVault(Type type = Type::Relaxed) : type_(type) {} + explicit SingletonVault(Type type = Type::Strict) : type_(type) {} // Destructor is only called by unit tests to check destroyInstances. ~SingletonVault(); @@ -507,9 +507,12 @@ class SingletonVault { eagerInitSingletons_; folly::Synchronized> creationOrder_; - folly::Synchronized state_; + // Using SharedMutexReadPriority is important here, because we want to make + // sure we don't block nested singleton creation happening concurrently with + // destroyInstances(). + folly::Synchronized state_; - Type type_{Type::Relaxed}; + Type type_; }; // This is the wrapper class that most users actually interact with.