MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ add_reader()

SerialDevice::ReaderToken MayaFlux::Core::SerialDevice::add_reader ( SerialSpec spec,
uint32_t id,
ValueCallback callback )

Read the same bytes a second way.

Parameters
specFraming and parsing of this reader. Its line setup is not used.
idId stamped on the values it produces.
callbackReceives each value, on the link's thread.
Returns
A token for remove_reader(), never 0.

The reader does not take part in requests, and it starts from a clean stream.

Definition at line 35 of file SerialDevice.cpp.

36{
37 auto reader = std::make_shared<SerialReader>(id, std::move(spec), *m_link);
38 reader->set_value_callback(std::move(callback));
39 const ReaderToken token = m_next_token.fetch_add(1);
40 m_readers.update([&](ReaderList& list) {
41 list.emplace_back(token, std::move(reader));
42 return true;
43 });
44 return token;
45}
Memory::SnapshotCell< ReaderList > m_readers
std::vector< std::pair< ReaderToken, std::shared_ptr< SerialReader > > > ReaderList
std::unique_ptr< ISerialLink > m_link
std::atomic< ReaderToken > m_next_token
const SerialSpec & spec() const

References m_link, m_next_token, m_readers, and spec().

Referenced by operator=().

Here is the call graph for this function:
Here is the caller graph for this function: