mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +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:
@@ -16,8 +16,6 @@
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
|
||||
Scheduler *Scheduler::_instance = nullptr;
|
||||
|
||||
Scheduler::Scheduler() {
|
||||
m_buttonsLock = initializeMutexNormal();
|
||||
m_additionsLock = initializeMutexNormal();
|
||||
@@ -38,8 +36,8 @@ Scheduler::~Scheduler() {
|
||||
* @return the {@link Scheduler}
|
||||
*/
|
||||
Scheduler *Scheduler::GetInstance() {
|
||||
if (_instance == nullptr) _instance = new Scheduler();
|
||||
return _instance;
|
||||
static Scheduler instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
void Scheduler::SetEnabled(bool enabled) { m_enabled = enabled; }
|
||||
|
||||
Reference in New Issue
Block a user