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

Detailed Description

template<class BlockType>
class foxxll::write_pool< BlockType >

Implements dynamically resizable buffered writing pool.

Definition at line 38 of file write_pool.hpp.

#include <write_pool.hpp>

Classes

struct  busy_entry
 

Public Types

using bid_type = typename block_type::bid_type
 
using block_type = BlockType
 
using busy_blocks_iterator = typename std::list< busy_entry >::iterator
 
using free_blocks_iterator = typename std::list< block_type * >::iterator
 

Public Member Functions

 write_pool (size_t init_size=1)
 
 write_pool (const write_pool &)=delete
 non-copyable: delete copy-constructor More...
 
 ~write_pool ()
 Waits for completion of all ongoing write requests and frees memory. More...
 
void add (block_type *&block)
 
bool has_request (bid_type bid)
 
write_pooloperator= (const write_pool &)=delete
 non-copyable: delete assignment operator More...
 
void resize (size_t new_size)
 
size_t size () const
 Returns number of owned blocks. More...
 
block_typesteal ()
 
std::pair< block_type
*, request_ptr
steal_request (bid_type bid)
 
void swap (write_pool &obj)
 
request_ptr write (block_type *&block, bid_type bid)
 

Protected Member Functions

void check_all_busy ()
 

Protected Attributes

std::list< busy_entrybusy_blocks
 
std::list< block_type * > free_blocks
 

Static Private Attributes

static constexpr bool debug = false
 

Member Typedef Documentation

using bid_type = typename block_type::bid_type

Definition at line 44 of file write_pool.hpp.

using block_type = BlockType

Definition at line 43 of file write_pool.hpp.

using busy_blocks_iterator = typename std::list<busy_entry>::iterator

Definition at line 61 of file write_pool.hpp.

using free_blocks_iterator = typename std::list<block_type*>::iterator

Definition at line 60 of file write_pool.hpp.

Constructor & Destructor Documentation

write_pool ( size_t  init_size = 1)
inlineexplicit

Constructs pool.

Parameters
init_sizeinitial number of blocks in the pool

Definition at line 72 of file write_pool.hpp.

References FOXXLL_VERBOSE_WPOOL, and write_pool< BlockType >::free_blocks.

write_pool ( const write_pool< BlockType > &  )
delete

non-copyable: delete copy-constructor

~write_pool ( )
inline

Waits for completion of all ongoing write requests and frees memory.

Definition at line 93 of file write_pool.hpp.

References write_pool< BlockType >::busy_blocks, FOXXLL_VERBOSE_WPOOL, and write_pool< BlockType >::free_blocks.

Member Function Documentation

void check_all_busy ( )
inlineprotected
bool has_request ( bid_type  bid)
inline
write_pool& operator= ( const write_pool< BlockType > &  )
delete

non-copyable: delete assignment operator

void resize ( size_t  new_size)
inline

Resizes size of the pool.

Parameters
new_sizenew size of the pool after the call

Definition at line 177 of file write_pool.hpp.

References FOXXLL_VERBOSE_WPOOL, write_pool< BlockType >::free_blocks, write_pool< BlockType >::size(), and write_pool< BlockType >::steal().

Referenced by read_write_pool< BlockType >::resize_write().

size_t size ( ) const
inline
block_type* steal ( )
inline

Take out a block from the pool.

Returns
pointer to the block. Ownership of the block goes to the caller.

Definition at line 154 of file write_pool.hpp.

References write_pool< BlockType >::busy_blocks, write_pool< BlockType >::check_all_busy(), FOXXLL_VERBOSE_WPOOL, write_pool< BlockType >::free_blocks, write_pool< BlockType >::size(), and foxxll::wait_any().

Referenced by write_pool< BlockType >::resize(), and read_write_pool< BlockType >::steal().

std::pair<block_type*, request_ptr> steal_request ( bid_type  bid)
inline
void swap ( write_pool< BlockType > &  obj)
inline
request_ptr write ( block_type *&  block,
bid_type  bid 
)
inline

Passes a block to the pool for writing.

Parameters
blockblock to write. Ownership of the block goes to the pool. block must be allocated dynamically with using new .
bidlocation, where to write
Warning
block must be allocated dynamically with using new .
Returns
request object of the write operation

Definition at line 131 of file write_pool.hpp.

References write_pool< BlockType >::busy_blocks, and FOXXLL_VERBOSE_WPOOL.

Referenced by read_write_pool< BlockType >::write().

Member Data Documentation

constexpr bool debug = false
staticprivate

Definition at line 40 of file write_pool.hpp.


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