A decorator class that adds a write buffer to an otherwise unbuffered sink. More...
#include <buffered_sink.hpp>
Public Member Functions | |
buffered_sink (const boost::intrusive_ptr< sink > &underlying_sink) | |
virtual void | write (size_t buf_size, const void *buf) |
virtual void | flush () |
virtual int | flush_hint () const |
virtual void | close () |
virtual bool | closed () const |
A decorator class that adds a write buffer to an otherwise unbuffered sink.
block_size:
buffered_sink allocates storage always in chunks to minimize resizing of the internal buffer.
maximum_size:
The maximum number of bytes buffered_sink should allocate.
hamcast::util::buffered_sink< block_size, maximum_size >::buffered_sink | ( | const boost::intrusive_ptr< sink > & | underlying_sink | ) |
Create a buffered sink that decorates underlying_sink
.
underlying_sink | The original sink. |
underlying_sink
is valid virtual void hamcast::util::buffered_sink< block_size, maximum_size >::close | ( | ) | [virtual] |
Close the data channel.
Implements hamcast::util::closeable.
virtual bool hamcast::util::buffered_sink< block_size, maximum_size >::closed | ( | ) | const [virtual] |
Check if the data channel is closed.
true
if this
is closed for read/write operations; otherwise false
. Implements hamcast::util::closeable.
virtual void hamcast::util::buffered_sink< block_size, maximum_size >::flush | ( | ) | [virtual] |
Force the data sink to flush any buffers.
Any | exception that might be thrown by write(). |
Implements hamcast::util::sink.
virtual int hamcast::util::buffered_sink< block_size, maximum_size >::flush_hint | ( | ) | const [virtual] |
Return the optimal block size for write operations.
Reimplemented from hamcast::util::sink.
virtual void hamcast::util::buffered_sink< block_size, maximum_size >::write | ( | size_t | buf_size, | |
const void * | buf | |||
) | [virtual] |
Writes buf_size
bytes from buf
to the sink.
buf_size | The number of bytes that should be written from buf . | |
buf | The buffer. |
ios_base::failure | on errors (e.g. if the sink is closed) |
Implements hamcast::util::sink.