Base module

ThreadedStreamReader

Threaded stream reader class.

ThreadedStreamReader

#include <icy/packetio.h>

Inherits: PacketStreamAdapter, Startable

Threaded stream reader class.

This class can be connected to a [PacketStream](icy-PacketStream.html#packetstream) to read input from any class that derives from std::istream. It's most regularly used for reading input files.

Public Attributes

ReturnNameDescription
PacketSignalemitter

emitter

PacketSignal emitter

Public Methods

ReturnNameDescription
ThreadedStreamReader inline#### Parameters
~ThreadedStreamReader inlineStops the reader thread and deletes the owned stream.
voidstart virtual inlineStarts the reader thread; emits one line per iteration as a RawPacket. Emits a FlagPacket with [PacketFlags::Final](api_icy.md#namespaceicy_1a3d1e0d9028d45b9ec824bf4306047f18abeae421a14a34f831c113f61323d1ab3) on EOF.
voidstop virtual inlineCancels the reader thread.
StreamT &stream inlineReturns the internal stream cast to StreamT.
std::istream &stream inline#### Returns

ThreadedStreamReader

inline

inline ThreadedStreamReader(std::istream * is)

Parameters

  • is Input stream to read from; takes ownership.

~ThreadedStreamReader

inline

inline ~ThreadedStreamReader()

Stops the reader thread and deletes the owned stream.


start

virtual inline

virtual inline void start()

Starts the reader thread; emits one line per iteration as a RawPacket. Emits a FlagPacket with [PacketFlags::Final](api_icy.md#namespaceicy_1a3d1e0d9028d45b9ec824bf4306047f18abeae421a14a34f831c113f61323d1ab3) on EOF.


stop

virtual inline

virtual inline void stop()

Cancels the reader thread.


stream

inline

template<class StreamT> inline StreamT & stream()

Returns the internal stream cast to StreamT.

Parameters

  • StreamT Target stream type derived from std::istream.

Returns

Reference to the cast stream.

Exceptions

  • std::runtime_error if the cast fails.

stream

inline

inline std::istream & stream()

Returns

Reference to the underlying input stream.

Protected Attributes

ReturnNameDescription
Thread_runner
std::istream *_istream

_runner

Thread _runner

_istream

std::istream * _istream