STXXL  1.4-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stxxl::read_write_pool< BlockType > Class Template Reference

Detailed Description

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

Implements dynamically resizable buffered writing and prefetched reading pool.

Definition at line 26 of file read_write_pool.h.

+ Inheritance diagram for stxxl::read_write_pool< BlockType >:
+ Collaboration diagram for stxxl::read_write_pool< BlockType >:

Public Types

typedef block_type::bid_type bid_type
 
typedef BlockType block_type
 
typedef unsigned_type size_type
 

Public Member Functions

 read_write_pool (size_type init_size_prefetch=1, size_type init_size_write=1)
 Constructs pool. More...
 
 read_write_pool (prefetch_pool_type &p_pool, write_pool_type &w_pool)
 
 ~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...
 
unsigned_type busy_size_prefetch () const
 Returns the number of busy prefetching blocks. More...
 
request_ptr find_hint (bid_type bid)
 Returns the request pointer for a hinted block, or an invalid NULL request in case it was not requested due to lack of prefetch buffers. More...
 
unsigned_type free_size_prefetch () const
 Returns the number of free prefetching blocks. More...
 
bool hint (bid_type bid)
 Gives a hint for prefetching a block. More...
 
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...
 
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)
 Resizes size of the pool. More...
 
void resize_write (size_type new_size)
 Resizes size of the pool. More...
 
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 ()
 Take out a block from the pool. More...
 
block_typesteal_prefetch ()
 Take out a block from the prefetch pool, one unhinted free block must be available. More...
 
void swap (read_write_pool &obj)
 
request_ptr write (block_type *&block, bid_type bid)
 Passes a block to the pool for writing. More...
 

Protected Types

typedef prefetch_pool< block_typeprefetch_pool_type
 
typedef write_pool< block_typewrite_pool_type
 

Protected Attributes

bool delete_pools
 
prefetch_pool_typep_pool
 
write_pool_typew_pool
 

Additional Inherited Members

- Private Member Functions inherited from stxxl::noncopyable
 noncopyable ()
 

Member Typedef Documentation

template<typename BlockType>
typedef block_type::bid_type stxxl::read_write_pool< BlockType >::bid_type

Definition at line 30 of file read_write_pool.h.

template<typename BlockType>
typedef BlockType stxxl::read_write_pool< BlockType >::block_type

Definition at line 29 of file read_write_pool.h.

template<typename BlockType>
typedef prefetch_pool<block_type> stxxl::read_write_pool< BlockType >::prefetch_pool_type
protected

Definition at line 35 of file read_write_pool.h.

template<typename BlockType>
typedef unsigned_type stxxl::read_write_pool< BlockType >::size_type

Definition at line 31 of file read_write_pool.h.

template<typename BlockType>
typedef write_pool<block_type> stxxl::read_write_pool< BlockType >::write_pool_type
protected

Definition at line 34 of file read_write_pool.h.

Constructor & Destructor Documentation

template<typename BlockType>
stxxl::read_write_pool< BlockType >::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 45 of file read_write_pool.h.

template<typename BlockType>
stxxl::read_write_pool< BlockType >::read_write_pool ( prefetch_pool_type p_pool,
write_pool_type w_pool 
)
inline

Definition at line 52 of file read_write_pool.h.

template<typename BlockType>
stxxl::read_write_pool< BlockType >::~read_write_pool ( )
inline

Waits for completion of all ongoing requests and frees memory.

Definition at line 64 of file read_write_pool.h.

Member Function Documentation

template<typename BlockType>
void stxxl::read_write_pool< BlockType >::add ( block_type *&  block)
inline

Add block to write pool.

Definition at line 120 of file read_write_pool.h.

template<typename BlockType>
unsigned_type stxxl::read_write_pool< BlockType >::busy_size_prefetch ( ) const
inline

Returns the number of busy prefetching blocks.

Definition at line 202 of file read_write_pool.h.

template<typename BlockType>
request_ptr stxxl::read_write_pool< BlockType >::find_hint ( bid_type  bid)
inline

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

Definition at line 164 of file read_write_pool.h.

template<typename BlockType>
unsigned_type stxxl::read_write_pool< BlockType >::free_size_prefetch ( ) const
inline

Returns the number of free prefetching blocks.

Definition at line 196 of file read_write_pool.h.

template<typename BlockType>
bool stxxl::read_write_pool< BlockType >::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 134 of file read_write_pool.h.

Referenced by stxxl::priority_queue_local::ext_merger< BlockType, CompareType, Arity, AllocStr >::prefetch_arrays().

template<typename BlockType>
bool stxxl::read_write_pool< BlockType >::in_prefetching ( bid_type  bid)
inline

Checks if a block is in the hinted block set.

Definition at line 190 of file read_write_pool.h.

template<typename BlockType>
bool stxxl::read_write_pool< BlockType >::invalidate ( bid_type  bid)
inline

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

Definition at line 140 of file read_write_pool.h.

template<typename BlockType>
bool stxxl::read_write_pool< BlockType >::poll_hint ( bid_type  bid)
inline

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

Definition at line 170 of file read_write_pool.h.

template<typename BlockType>
request_ptr stxxl::read_write_pool< BlockType >::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 157 of file read_write_pool.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::hint_next_block(), stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::read_block(), and stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::rebuild_hints_finish().

template<typename BlockType>
void stxxl::read_write_pool< BlockType >::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 87 of file read_write_pool.h.

Referenced by stxxl::random_shuffle().

template<typename BlockType>
void stxxl::read_write_pool< BlockType >::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 80 of file read_write_pool.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::prepare_write_pool(), and stxxl::random_shuffle().

template<typename BlockType>
size_type stxxl::read_write_pool< BlockType >::size_prefetch ( ) const
inline

Returns number of blocks owned by the prefetch_pool.

Definition at line 76 of file read_write_pool.h.

template<typename BlockType>
block_type* stxxl::read_write_pool< BlockType >::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 114 of file read_write_pool.h.

Referenced by stxxl::priority_queue_local::ext_merger< BlockType, CompareType, Arity, AllocStr >::append_merger(), and stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::read_block().

template<typename BlockType>
block_type* stxxl::read_write_pool< BlockType >::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 184 of file read_write_pool.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::hint_next_block(), and stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::rebuild_hints_finish().

template<typename BlockType>
void stxxl::read_write_pool< BlockType >::swap ( read_write_pool< BlockType > &  obj)
inline

Definition at line 56 of file read_write_pool.h.

template<typename BlockType>
request_ptr stxxl::read_write_pool< BlockType >::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 100 of file read_write_pool.h.

Referenced by stxxl::priority_queue_local::ext_merger< BlockType, CompareType, Arity, AllocStr >::append_merger(), and stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::write_block().

Member Data Documentation

template<typename BlockType>
bool stxxl::read_write_pool< BlockType >::delete_pools
protected

Definition at line 39 of file read_write_pool.h.

Referenced by stxxl::read_write_pool< block_type >::swap().

template<typename BlockType>
prefetch_pool_type* stxxl::read_write_pool< BlockType >::p_pool
protected

Definition at line 38 of file read_write_pool.h.

Referenced by stxxl::read_write_pool< block_type >::swap().

template<typename BlockType>
write_pool_type* stxxl::read_write_pool< BlockType >::w_pool
protected

Definition at line 37 of file read_write_pool.h.

Referenced by stxxl::read_write_pool< block_type >::swap().


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