byteme
Read/write bytes from various sources
Loading...
Searching...
No Matches
byteme::ParallelBufferedWriter< Type_, Pointer_ > Class Template Referencefinal

Parallelized buffering to wrap a Writer. More...

#include <BufferedWriter.hpp>

Inheritance diagram for byteme::ParallelBufferedWriter< Type_, Pointer_ >:
Collaboration diagram for byteme::ParallelBufferedWriter< Type_, Pointer_ >:

Public Member Functions

 ParallelBufferedWriter (Pointer_ writer, std::size_t buffer_size)
 
void finish ()
 
- Public Member Functions inherited from byteme::BufferedWriter< Type_, WriterPointer_ >
unsigned long long number ()
 
void write (Type_ input)
 
void write (const Type_ *input, std::size_t number)
 
void write (const char *string)
 
void write (const std::string &string)
 
void flush ()
 

Detailed Description

template<typename Type_, class Pointer_ = std::unique_ptr<Writer>>
class byteme::ParallelBufferedWriter< Type_, Pointer_ >

Parallelized buffering to wrap a Writer.

Template Parameters
Type_Type of the output bytes, usually char for text or unsigned char for binary.
Pointer_Pointer to a class that serves as a source of input bytes. The pointed-to class should satisfy the Writer interface; it may also be a concrete Writer subclass to enable devirtualization. Either a smart or raw pointer may be supplied depending on how the caller wants to manage the lifetime of the pointed-to object.

This is a subclass of BufferedWriter that calls Writer::write() on a worker thread. The user can fill up the next buffer while the current buffer is flushed to the underlying representation.

Constructor & Destructor Documentation

◆ ParallelBufferedWriter()

template<typename Type_ , class Pointer_ = std::unique_ptr<Writer>>
byteme::ParallelBufferedWriter< Type_, Pointer_ >::ParallelBufferedWriter ( Pointer_ writer,
std::size_t buffer_size )
inline
Parameters
writerPointer to a source of input bytes.
buffer_sizeSize of the internal buffer in which to store bytes that have been passed to write() but not yet flushed to the writer. Larger values reduce the number of write calls at the cost of greater memory usage. Should be positive.

Member Function Documentation

◆ finish()

template<typename Type_ , class Pointer_ = std::unique_ptr<Writer>>
void byteme::ParallelBufferedWriter< Type_, Pointer_ >::finish ( )
inlinevirtual

Flush all currently-buffered bytes to the underlying Writer instance and call Writer::finish(). This terminates the write stream so no further calls to write(), flush() or finish() may be performed. It is not called automatically upon BufferedWriter destruction, as the user may want to write further bytes to the same Writer instance after exiting the BufferedWriter wrapper.

Implements byteme::BufferedWriter< Type_, WriterPointer_ >.


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