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

Detailed Description

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

Implements dynamically resizable buffered writing and prefetched reading pool.

Definition at line 31 of file read_write_pool.hpp.

+ Collaboration diagram for read_write_pool< BlockType >:

#include <read_write_pool.hpp>

Public Types

using bid_type = typename block_type::bid_type
 
using block_type = BlockType
 
using size_type = size_t
 

Public Member Functions

 read_write_pool (size_type init_size_prefetch=1, size_type init_size_write=1)
 
 read_write_pool (const read_write_pool &)=delete
 non-copyable: delete copy-constructor More...
 
 ~read_write_pool ()
 Waits for completion of all ongoing requests and frees memory. More...
 
void add (block_type *&block)
 Add block to write pool. More...
 
void add_prefetch (block_type *&block)
 Add block to prefetch pool. More...
 
size_t busy_size_prefetch () const
 Returns the number of busy prefetching blocks. More...
 
request_ptr find_hint (bid_type bid)
 
size_t free_size_prefetch () const
 Returns the number of free prefetching blocks. More...
 
bool hint (bid_type bid)
 
bool in_prefetching (bid_type bid)
 Checks if a block is in the hinted block set. More...
 
bool invalidate (bid_type bid)
 Cancel a hint request in case the block is no longer desired. More...
 
read_write_pooloperator= (const read_write_pool &)=delete
 non-copyable: delete assignment operator More...
 
bool poll_hint (bid_type bid)
 Returns true if the blocks was hinted and the request is finished. More...
 
request_ptr read (block_type *&block, bid_type bid)
 Reads block. More...
 
void resize_prefetch (size_type new_size)
 
void resize_write (size_type new_size)
 
size_type size_prefetch () const
 Returns number of blocks owned by the prefetch_pool. More...
 
size_type size_write () const
 Returns number of blocks owned by the write_pool. More...
 
block_typesteal ()
 
block_typesteal_prefetch ()
 
void swap (read_write_pool &obj)
 
request_ptr write (block_type *&block, bid_type bid)
 

Protected Types

using prefetch_pool_type = prefetch_pool< block_type >
 
using write_pool_type = write_pool< block_type >
 

Protected Attributes

bool delete_pools
 
prefetch_pool_typep_pool
 
write_pool_typew_pool
 

Member Typedef Documentation

using bid_type = typename block_type::bid_type

Definition at line 35 of file read_write_pool.hpp.

using block_type = BlockType

Definition at line 34 of file read_write_pool.hpp.

Definition at line 40 of file read_write_pool.hpp.

using size_type = size_t

Definition at line 36 of file read_write_pool.hpp.

Definition at line 39 of file read_write_pool.hpp.

Constructor & Destructor Documentation

read_write_pool ( size_type  init_size_prefetch = 1,
size_type  init_size_write = 1 
)
inlineexplicit

Constructs pool.

Parameters
init_size_prefetchinitial number of blocks in the prefetch pool
init_size_writeinitial number of blocks in the write pool

Definition at line 50 of file read_write_pool.hpp.

References read_write_pool< BlockType >::p_pool, and read_write_pool< BlockType >::w_pool.

read_write_pool ( const read_write_pool< BlockType > &  )
delete

non-copyable: delete copy-constructor

~read_write_pool ( )
inline

Waits for completion of all ongoing requests and frees memory.

Definition at line 70 of file read_write_pool.hpp.

References read_write_pool< BlockType >::delete_pools, read_write_pool< BlockType >::p_pool, and read_write_pool< BlockType >::w_pool.

Member Function Documentation

void add ( block_type *&  block)
inline

Add block to write pool.

Definition at line 126 of file read_write_pool.hpp.

References write_pool< BlockType >::add(), and read_write_pool< BlockType >::w_pool.

void add_prefetch ( block_type *&  block)
inline

Add block to prefetch pool.

Definition at line 182 of file read_write_pool.hpp.

References prefetch_pool< BlockType >::add(), and read_write_pool< BlockType >::p_pool.

size_t busy_size_prefetch ( ) const
inline

Returns the number of busy prefetching blocks.

Definition at line 208 of file read_write_pool.hpp.

References prefetch_pool< BlockType >::busy_size(), and read_write_pool< BlockType >::p_pool.

request_ptr find_hint ( bid_type  bid)
inline

Returns the request pointer for a hinted block, or an invalid nullptr request in case it was not requested due to lack of prefetch buffers.

Definition at line 170 of file read_write_pool.hpp.

References prefetch_pool< BlockType >::find(), and read_write_pool< BlockType >::p_pool.

size_t free_size_prefetch ( ) const
inline

Returns the number of free prefetching blocks.

Definition at line 202 of file read_write_pool.hpp.

References prefetch_pool< BlockType >::free_size(), and read_write_pool< BlockType >::p_pool.

bool hint ( bid_type  bid)
inline

Gives a hint for prefetching a block.

Parameters
bidaddress of a block to be prefetched
Returns
true if there was a free block to do prefetch and prefetching was scheduled, false otherwise
Note
If there are no free blocks available (all blocks are already in reading or read but not retrieved by user calling read method) calling hint function has no effect

Definition at line 140 of file read_write_pool.hpp.

References prefetch_pool< BlockType >::hint(), read_write_pool< BlockType >::p_pool, and read_write_pool< BlockType >::w_pool.

bool in_prefetching ( bid_type  bid)
inline

Checks if a block is in the hinted block set.

Definition at line 196 of file read_write_pool.hpp.

References prefetch_pool< BlockType >::in_prefetching(), and read_write_pool< BlockType >::p_pool.

bool invalidate ( bid_type  bid)
inline

Cancel a hint request in case the block is no longer desired.

Definition at line 146 of file read_write_pool.hpp.

References prefetch_pool< BlockType >::invalidate(), and read_write_pool< BlockType >::p_pool.

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

non-copyable: delete assignment operator

bool poll_hint ( bid_type  bid)
inline

Returns true if the blocks was hinted and the request is finished.

Definition at line 176 of file read_write_pool.hpp.

References read_write_pool< BlockType >::p_pool, and prefetch_pool< BlockType >::poll().

request_ptr read ( block_type *&  block,
bid_type  bid 
)
inline

Reads block.

If this block is cached block is not read but passed from the cache.

Parameters
blockblock object, where data to be read to. If block was cached block 's ownership goes to the pool and block from cache is returned in block value.
bidaddress of the block
Warning
block parameter must be allocated dynamically using new .
Returns
request pointer object of read operation

Definition at line 163 of file read_write_pool.hpp.

References read_write_pool< BlockType >::p_pool, prefetch_pool< BlockType >::read(), and read_write_pool< BlockType >::w_pool.

void resize_prefetch ( size_type  new_size)
inline

Resizes size of the pool.

Parameters
new_sizenew size of the pool after the call

Definition at line 93 of file read_write_pool.hpp.

References read_write_pool< BlockType >::p_pool, and prefetch_pool< BlockType >::resize().

void resize_write ( size_type  new_size)
inline

Resizes size of the pool.

Parameters
new_sizenew size of the pool after the call

Definition at line 86 of file read_write_pool.hpp.

References write_pool< BlockType >::resize(), and read_write_pool< BlockType >::w_pool.

size_type size_prefetch ( ) const
inline

Returns number of blocks owned by the prefetch_pool.

Definition at line 82 of file read_write_pool.hpp.

References read_write_pool< BlockType >::p_pool, and prefetch_pool< BlockType >::size().

size_type size_write ( ) const
inline

Returns number of blocks owned by the write_pool.

Definition at line 79 of file read_write_pool.hpp.

References write_pool< BlockType >::size(), and read_write_pool< BlockType >::w_pool.

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 120 of file read_write_pool.hpp.

References write_pool< BlockType >::steal(), and read_write_pool< BlockType >::w_pool.

block_type* steal_prefetch ( )
inline

Take out a block from the prefetch pool, one unhinted free block must be available.

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

Definition at line 190 of file read_write_pool.hpp.

References read_write_pool< BlockType >::p_pool, and prefetch_pool< BlockType >::steal().

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 106 of file read_write_pool.hpp.

References prefetch_pool< BlockType >::hint(), prefetch_pool< BlockType >::invalidate(), read_write_pool< BlockType >::p_pool, read_write_pool< BlockType >::w_pool, and write_pool< BlockType >::write().

Member Data Documentation

bool delete_pools
protected

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