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:
@@ -26,7 +26,6 @@ const uint32_t DriverStation::kBatteryChannel;
|
||||
const uint32_t DriverStation::kJoystickPorts;
|
||||
const uint32_t DriverStation::kJoystickAxes;
|
||||
constexpr float DriverStation::kUpdatePeriod;
|
||||
DriverStation* DriverStation::m_instance = nullptr;
|
||||
uint8_t DriverStation::m_updateNumber = 0;
|
||||
|
||||
/**
|
||||
@@ -70,7 +69,6 @@ DriverStation::DriverStation()
|
||||
|
||||
DriverStation::~DriverStation()
|
||||
{
|
||||
m_instance = nullptr;
|
||||
deleteMultiWait(m_waitForDataSem);
|
||||
deleteMutex(m_waitForDataMutex);
|
||||
// TODO: Release m_stateSemaphore and m_joystickSemaphore?
|
||||
@@ -81,11 +79,8 @@ DriverStation::~DriverStation()
|
||||
*/
|
||||
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