Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
buffered_writer< BlockType > Class Template Reference

Detailed Description

template<typename BlockType>
class foxxll::buffered_writer< BlockType >

Encapsulates asynchronous buffered block writing engine.

buffered_writer overlaps I/Os with filling of output buffer.

Definition at line 35 of file buf_writer.hpp.

+ Inheritance diagram for buffered_writer< BlockType >:
+ Collaboration diagram for buffered_writer< BlockType >:

#include <buf_writer.hpp>

Classes

struct  batch_entry
 
struct  batch_entry_cmp
 

Public Member Functions

 buffered_writer (size_t write_buf_size, size_t write_batch_size)
 
 buffered_writer (const buffered_writer &)=delete
 non-copyable: delete copy-constructor More...
 
 ~buffered_writer ()
 Flushes not yet written buffers and frees used memory. More...
 
void flush ()
 Flushes not yet written buffers. More...
 
block_typeget_free_block ()
 
buffered_writeroperator= (const buffered_writer &)=delete
 non-copyable: delete assignment operator More...
 
block_typewrite (block_type *filled_block, const bid_type &bid)
 

Protected Types

using batch_type = std::priority_queue< batch_entry, std::vector< batch_entry >, batch_entry_cmp >
 

Protected Attributes

batch_type batch_write_blocks
 
std::vector< size_t > busy_write_blocks
 
std::vector< size_t > free_write_blocks
 
const size_t nwriteblocks
 
bid_typewrite_bids
 
block_typewrite_buffers
 
request_ptrwrite_reqs
 
const size_t writebatchsize
 

Private Types

using bid_type = typename block_type::bid_type
 
using block_type = BlockType
 

Static Private Attributes

static constexpr bool debug = false
 

Member Typedef Documentation

using batch_type = std::priority_queue<batch_entry, std::vector<batch_entry>, batch_entry_cmp>
protected

Definition at line 66 of file buf_writer.hpp.

using bid_type = typename block_type::bid_type
private

Definition at line 39 of file buf_writer.hpp.

using block_type = BlockType
private

Definition at line 38 of file buf_writer.hpp.

Constructor & Destructor Documentation

buffered_writer ( size_t  write_buf_size,
size_t  write_batch_size 
)
inline

Constructs an object.

Parameters
write_buf_sizenumber of write buffers to use
write_batch_sizenumber of blocks to accumulate in order to flush write requests (bulk buffered writing)

Definition at line 74 of file buf_writer.hpp.

buffered_writer ( const buffered_writer< BlockType > &  )
delete

non-copyable: delete copy-constructor

~buffered_writer ( )
inline

Flushes not yet written buffers and frees used memory.

Definition at line 192 of file buf_writer.hpp.

Member Function Documentation

void flush ( )
inline

Flushes not yet written buffers.

Definition at line 162 of file buf_writer.hpp.

block_type* get_free_block ( )
inline

Returns free block from the internal buffer pool.

Returns
pointer to the block from the internal buffer pool

Definition at line 96 of file buf_writer.hpp.

Referenced by buf_ostream< BlockType, BidIteratorType >::buf_ostream(), and buffered_writer< block_type >::write().

buffered_writer& operator= ( const buffered_writer< BlockType > &  )
delete

non-copyable: delete assignment operator

block_type* write ( block_type filled_block,
const bid_type bid 
)
inline

Submits block for writing.

Parameters
filled_blockpointer to the block
Remarks
parameter filled_block must be value returned by get_free_block() or write() methods
Parameters
bidblock identifier, a place to write data of the filled_block
Returns
pointer to the new free block from the pool

Definition at line 135 of file buf_writer.hpp.

Referenced by buf_ostream< BlockType, BidIteratorType >::flush(), buf_ostream< BlockType, BidIteratorType >::operator++(), and buf_ostream< BlockType, BidIteratorType >::operator<<().

Member Data Documentation

constexpr bool debug = false
staticprivate

Definition at line 37 of file buf_writer.hpp.

std::vector<size_t> free_write_blocks
protected
const size_t nwriteblocks
protected
const size_t writebatchsize
protected

Definition at line 46 of file buf_writer.hpp.

Referenced by buffered_writer< block_type >::write().


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