#pragma once #include #include "lasp_streammgr.h" const us RINGBUFFER_SIZE = 1024; /** * \addtogroup dsp * @{ * * \defgroup rt Real time signal handlers * @{ */ class SafeQueue; /** * @brief Threaded in data handler. Buffers inCallback data and calls a * callback with the same signature on a different thread. */ class ThreadedInDataHandler: public InDataHandler { /** * @brief The queue used to push elements to the handling thread. */ std::unique_ptr _queue; std::atomic _thread_running{false}; std::atomic _stopThread{false}; std::atomic _lastCallbackResult{true}; void threadFcn(); public: /** * @brief Initialize a ThreadedInDataHandler * * @param mgr StreamMgr singleton reference */ ThreadedInDataHandler(StreamMgr& mgr); ~ThreadedInDataHandler(); /** * @brief Pushes a copy of the daqdata to the thread queue and returns * * @param daqdata the daq info to push * * @return true, to continue with sampling. */ virtual bool inCallback(const DaqData &daqdata) override final; /** * @brief This function should be overridden with an actual implementation, * of what should happen on a different thread. * * @param DaqData Input daq data * * @return true on succes. False when an error occured. */ virtual bool inCallback_threaded(const DaqData&) = 0; }; /** @} */ /** @} */