XT-neighbor
Public Member Functions | List of all members
RAMSwapStream< T > Class Template Reference

A stream with bin packing capability backed by RAM. More...

Public Member Functions

size_t get_total_len ()
 
void set_max_readable_size (int maxReadableSize)
 
Chunk< T > read ()
 
void write (T *newData, int n)
 
void swap ()
 
void deconstruct ()
 

Detailed Description

template<typename T>
class RAMSwapStream< T >

A stream with bin packing capability backed by RAM.

It contains 2 queues for duplex transfer: reading and writing queues. The duplex works by taking turns at the end of each stream as follow. First, when the buffer is empty, it is write-only. All writing is done to until depleted. Second, the "swap" is performed and the writing buffer now become reading now the writing buffer is cleared. Third, start duplexing (read from reading buffer and write to writing buffer). Last, once stream is depleted, repeat second step.

Note that the memory is immediately deallocated after each read to keep the memory requirement relatively constant.

Member Function Documentation

◆ deconstruct()

template<typename T >
void RAMSwapStream< T >::deconstruct ( )
inline

◆ get_total_len()

template<typename T >
size_t RAMSwapStream< T >::get_total_len ( )
inline

◆ read()

template<typename T >
Chunk<T> RAMSwapStream< T >::read ( )
inline

◆ set_max_readable_size()

template<typename T >
void RAMSwapStream< T >::set_max_readable_size ( int  maxReadableSize)
inline

◆ swap()

template<typename T >
void RAMSwapStream< T >::swap ( )
inline

◆ write()

template<typename T >
void RAMSwapStream< T >::write ( T *  newData,
int  n 
)
inline

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