25 #include "cheetah/psrdada/DadaReadClient.h" 26 #include "panda/Error.h" 27 #include "panda/Log.h" 35 template <
typename Iterator,
typename DataType>
38 std::shared_ptr<bool> destructor_flag(_destructor_flag);
45 if (!_current_reader || _current_reader->empty())
47 if (!acquire_data_block())
52 begin = _current_reader->read<DataType>(begin, end);
57 template <
typename CallBackFunctor>
61 _engine.post(std::bind(&DadaReadClient::do_next_sequence<CallBackFunctor>,
this,_destructor_flag, callback));
64 template <
typename CallBack>
65 void DadaReadClient::do_next_sequence(std::shared_ptr<bool> destructor_flag, CallBack callback)
72 PANDA_LOG_DEBUG <<
id() <<
"Acquiring next header block";
79 tmp = ipcbuf_get_next_read(_hdu->header_block, &nbytes);
86 _log.
write(LOG_ERR,
"Could not acquire next header block\n");
89 auto deleter = [&](std::istream* i)
96 PANDA_LOG_DEBUG <<
id() <<
"Releasing header block";
97 if (ipcbuf_mark_cleared(_hdu->header_block) < 0)
99 _log.
write(LOG_ERR,
"Could not mark cleared header block\n");
100 PANDA_LOG_ERROR <<
"Could not mark cleared header block";
104 std::unique_ptr<std::istream, decltype(deleter)> header(
new std::istream(&sbuf), deleter);
105 callback(*header,std::current_exception());
109 std::stringstream sbuf(
" ");
110 callback(sbuf, std::current_exception());
114 std::shared_ptr<bool> DadaReadClient::stopped()
const 116 return _destructor_flag;
Some limits and constants for FLDO.
void next_sequence()
Move to the next sequence in the ring buffer.
Iterator & read(Iterator &begin, Iterator const &end)
Read from the data ring buffer.
std::string const & id() const
Return a string identifier based on the buffer key and log name.
void write(int priority, const char *format, Args &&... args)
Write to the log.