DevReattacher: Spinlock-protect stop() call
Replace the current delay timeout mechanism with a spinlock. Both mechanisms try to eliminate the possibility of an in-flight async op accessing state that has been destroyed by stop(). But the spinlock is less arbitrary.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <spinLock.h>
|
||||
|
||||
namespace smo {
|
||||
|
||||
@@ -35,7 +36,8 @@ private:
|
||||
|
||||
DeviceManager &parent;
|
||||
std::shared_ptr<ComponentThread> ioThread;
|
||||
std::atomic<bool> shouldContinue;
|
||||
SpinLock shouldContinueLock;
|
||||
bool shouldContinue;
|
||||
boost::asio::deadline_timer timer;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user