Thrill  0.1

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_ptrsteal_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

◆ bid_type

using bid_type = typename block_type::bid_type

Definition at line 44 of file write_pool.hpp.

◆ block_type

using block_type = BlockType

Definition at line 43 of file write_pool.hpp.

◆ busy_blocks_iterator

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

Definition at line 61 of file write_pool.hpp.

◆ free_blocks_iterator

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

Definition at line 60 of file write_pool.hpp.

Constructor & Destructor Documentation

◆ write_pool() [1/2]

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 >::operator=().

◆ write_pool() [2/2]

write_pool ( const write_pool< BlockType > &  )
delete

non-copyable: delete copy-constructor

◆ ~write_pool()

~write_pool ( )
inline

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

Definition at line 93 of file write_pool.hpp.

References FOXXLL_VERBOSE_WPOOL.

Member Function Documentation

◆ add()

◆ check_all_busy()

void check_all_busy ( )
inlineprotected

Definition at line 235 of file write_pool.hpp.

References FOXXLL_VERBOSE_WPOOL.

Referenced by write_pool< BlockType >::steal().

◆ has_request()

bool has_request ( bid_type  bid)
inline

◆ operator=()

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

non-copyable: delete assignment operator

Referenced by write_pool< BlockType >::write_pool().

◆ resize()

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 >::size(), and write_pool< BlockType >::steal().

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

◆ size()

size_t size ( ) const
inline

Returns number of owned blocks.

Definition at line 123 of file write_pool.hpp.

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

◆ steal()

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 >::check_all_busy(), FOXXLL_VERBOSE_WPOOL, write_pool< BlockType >::size(), and foxxll::wait_any().

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

◆ steal_request()

std::pair<block_type*, request_ptr> steal_request ( bid_type  bid)
inline

◆ swap()

void swap ( write_pool< BlockType > &  obj)
inline

Definition at line 86 of file write_pool.hpp.

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

Referenced by std::swap().

◆ write()

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_entry::busy_entry(), and FOXXLL_VERBOSE_WPOOL.

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

Member Data Documentation

◆ busy_blocks

std::list<busy_entry> busy_blocks
protected

Definition at line 67 of file write_pool.hpp.

Referenced by write_pool< BlockType >::swap().

◆ debug

constexpr bool debug = false
staticprivate

Definition at line 40 of file write_pool.hpp.

◆ free_blocks

std::list<block_type*> free_blocks
protected

Definition at line 65 of file write_pool.hpp.

Referenced by write_pool< BlockType >::swap().


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