LASP 1.0
Library for Acoustic Signal Processing
Loading...
Searching...
No Matches
lasp_threadedindatahandler.h
Go to the documentation of this file.
1#pragma once
2#include "debugtrace.hpp"
4#include "lasp_thread.h"
5#include <atomic>
6#include <memory>
7#include <mutex>
8
9using std::placeholders::_1;
10const us RINGBUFFER_SIZE = 1024;
11
20class SafeQueue;
32 InDataHandler _indatahandler;
33 std::unique_ptr<SafeQueue> _queue;
34
35 mutable std::recursive_mutex _mtx;
36
37 std::atomic<bool> _thread_running{false};
38 std::atomic<bool> _thread_can_safely_run{false};
39
40 GlobalThreadPool _pool;
41
45 const InCallbackType inCallback;
46
47 void threadFcn();
48
49
58 void _inCallbackFromInDataHandler(const DaqData &daqdata);
59
60 public:
67 void startThread();
74 void stopThread();
75
76};
77
95template <typename Derived>
97 public:
100 std::bind(&ThreadedInDataHandler::_inCallback, this, _1),
101 std::bind(&ThreadedInDataHandler::_reset, this, _1))
102 {
103
104 }
105
106 void _reset(const Daq* daq) {
107 DEBUGTRACE_ENTER;
108 return static_cast<Derived*>(this)->reset(daq);
109 }
110 void _inCallback(const DaqData& data) {
111 DEBUGTRACE_ENTER;
112 return static_cast<Derived*>(this)->inCallback(data);
113 }
114};
115
Data coming from / going to DAQ. Non-interleaved format, which means data in buffer is ordered by cha...
Base cass for all DAQ (Data Acquisition) interfaces. A DAQ can be a custom device,...
Definition lasp_daq.h:29
Simple wrapper around BS::thread_pool that makes a BS::thread_pool a singleton, such that a thread po...
Definition lasp_thread.h:10
Threaded in data handler base. Buffers inCallback data and calls a callback with the same signature o...
void startThread()
This method should be called from the derived class' constructor, to start the thread and data is inc...
void stopThread()
This method SHOULD be called from all classes that derive on ThreadedInDataHandler....
A bit of curiously recurring template pattern, to connect the specific handlers and connect the prope...
void _inCallback(const DaqData &data)
std::function< void(const Daq *)> InResetType
Function definition for the reset callback.
std::function< void(const DaqData &)> InCallbackType
The function definition of callbacks with incoming DAQ data.
std::shared_ptr< StreamMgr > SmgrHandle
const us RINGBUFFER_SIZE
size_t us
We often use boolean values.
Definition lasp_types.h:29