mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
artf4107: GetInstance() calls are now atomic
C++11 guarantees construction of static variables to be atomic, so this patch takes advantage of that. Change-Id: I4a3db0f19c5fa5461fef3b6b63d7b8fec596c962
This commit is contained in:
@@ -24,8 +24,6 @@ static const char *kFileName = "/home/lvuser/wpilib-preferences.ini";
|
||||
static const char *kValuePrefix = "=\"";
|
||||
/** The characters to put after the value */
|
||||
static const char *kValueSuffix = "\"\n";
|
||||
/** The singleton instance */
|
||||
Preferences *Preferences::_instance = nullptr;
|
||||
|
||||
Preferences::Preferences()
|
||||
: m_readTask("PreferencesReadTask", (FUNCPTR)Preferences::InitReadTask),
|
||||
@@ -54,8 +52,8 @@ Preferences::~Preferences() {
|
||||
* @return pointer to the {@link Preferences}
|
||||
*/
|
||||
Preferences *Preferences::GetInstance() {
|
||||
if (_instance == nullptr) _instance = new Preferences;
|
||||
return _instance;
|
||||
static Preferences instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user