mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Updated Notifier to match changes in gerrit 1171
some changes were ommitted because they don't exist in sim Change-Id: I6901998635f73c14efc894c408d2b5fd98e4d94c
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
Notifier *Notifier::timerQueueHead = nullptr;
|
||||
priority_recursive_mutex Notifier::queueMutex;
|
||||
int Notifier::refcount = 0;
|
||||
std::atomic<int> Notifier::refcount{0};
|
||||
std::thread Notifier::m_task;
|
||||
std::atomic<bool> Notifier::m_stopped(false);
|
||||
|
||||
@@ -34,11 +34,9 @@ Notifier::Notifier(TimerEventHandler handler, void *param)
|
||||
{
|
||||
std::lock_guard<priority_recursive_mutex> sync(queueMutex);
|
||||
// do the first time intialization of static variables
|
||||
if (refcount == 0)
|
||||
{
|
||||
if (refcount.fetch_add(1) == 0) {
|
||||
m_task = std::thread(Run);
|
||||
}
|
||||
refcount++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +52,7 @@ Notifier::~Notifier()
|
||||
DeleteFromQueue();
|
||||
|
||||
// Delete the static variables when the last one is going away
|
||||
if (!(--refcount))
|
||||
if (refcount.fetch_sub(1) == 1)
|
||||
{
|
||||
m_stopped = true;
|
||||
m_task.join();
|
||||
|
||||
Reference in New Issue
Block a user