InterruptableSensorBase: Fix callback function deletion (#1807)

Save the callback function into a unique_ptr member instead.
This commit is contained in:
Thad House
2019-08-04 20:25:25 -07:00
committed by Peter Johnson
parent 810e58ea85
commit 6411bd79c6
3 changed files with 17 additions and 17 deletions

View File

@@ -7,8 +7,8 @@
#pragma once
#include <atomic>
#include <functional>
#include <memory>
#include <hal/Interrupts.h>
@@ -144,8 +144,8 @@ class InterruptableSensorBase : public ErrorBase, public SendableBase {
virtual void SetUpSourceEdge(bool risingEdge, bool fallingEdge);
protected:
// atomic for proper destruction
std::atomic<HAL_InterruptHandle> m_interrupt{HAL_kInvalidHandle};
HAL_InterruptHandle m_interrupt{HAL_kInvalidHandle};
std::unique_ptr<InterruptEventHandler> m_interruptHandler{nullptr};
void AllocateInterrupts(bool watcher);
};