mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21: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:
@@ -28,7 +28,6 @@ const double JOYSTICK_UNPLUGGED_MESSAGE_INTERVAL = 1.0;
|
||||
Log().Get(level)
|
||||
|
||||
const uint32_t DriverStation::kJoystickPorts;
|
||||
DriverStation* DriverStation::m_instance = nullptr;
|
||||
|
||||
/**
|
||||
* DriverStation constructor.
|
||||
@@ -73,7 +72,6 @@ DriverStation::DriverStation() {
|
||||
|
||||
DriverStation::~DriverStation() {
|
||||
m_task.Stop();
|
||||
m_instance = nullptr;
|
||||
deleteMultiWait(m_waitForDataSem);
|
||||
// Unregister our semaphore.
|
||||
HALSetNewDataSem(nullptr);
|
||||
@@ -111,10 +109,8 @@ void DriverStation::Run() {
|
||||
* @return Pointer to the DS instance
|
||||
*/
|
||||
DriverStation* DriverStation::GetInstance() {
|
||||
if (m_instance == nullptr) {
|
||||
m_instance = new DriverStation();
|
||||
}
|
||||
return m_instance;
|
||||
static DriverStation instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user