TinyRobotics
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
SynchronizedStream Class Reference

Wrapper class that can turn any Stream into a thread save implementation. This is done by adding a Mutex to the Stream. The read and write operations are buffered and the access to the stream is protected by the Mutex. More...

#include <SynchronizedStream.h>

Inheritance diagram for SynchronizedStream:
Inheritance graph
[legend]
Collaboration diagram for SynchronizedStream:
Collaboration graph
[legend]

Public Member Functions

 SynchronizedStream (Stream &stream, MutexBase &mutex)
 
int read () override
 
int peek () override
 
size_t write (uint8_t data) override
 
int available () override
 
int availableForWrite () override
 
void setBufferSize (int size)
 Defines the size of the internal buffers.
 

Protected Attributes

Stream * p_stream = nullptr
 
MutexBasep_mutex = nullptr
 
SingleBuffer< uint8_t > read_buffer
 
SingleBuffer< uint8_t > write_buffer
 

Detailed Description

Wrapper class that can turn any Stream into a thread save implementation. This is done by adding a Mutex to the Stream. The read and write operations are buffered and the access to the stream is protected by the Mutex.

Author
Phil Schatzmann

The documentation for this class was generated from the following file: