Stxxl  1.3.2
Public Types | Public Member Functions | Protected Types | Protected Attributes | List of all members
read_write_pool< BlockType > Class Template Reference

Implements dynamically resizable buffered writing and prefetched reading pool. More...

#include <read_write_pool.h>

Inherits noncopyable.

Collaboration diagram for read_write_pool< BlockType >:
Collaboration graph
[legend]

Public Types

typedef BlockType block_type
 
typedef block_type::bid_type bid_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...
 
 _STXXL_DEPRECATED (read_write_pool(prefetch_pool_type &p_pool, write_pool_type &w_pool))
 
void swap (read_write_pool &obj)
 
virtual ~read_write_pool ()
 Waits for completion of all ongoing requests and frees memory. More...
 
size_type size_write () const
 Returns number of blocks owned by the write_pool. More...
 
size_type size_prefetch () const
 Returns number of blocks owned by the prefetch_pool. More...
 
void resize_write (size_type new_size)
 Resizes size of the pool. More...
 
void resize_prefetch (size_type new_size)
 Resizes size of the pool. More...
 
request_ptr write (block_type *&block, bid_type bid)
 Passes a block to the pool for writing. More...
 
block_type * steal ()
 Take out a block from the pool. More...
 
void add (block_type *&block)
 
bool hint (bid_type bid)
 Gives a hint for prefetching a block. More...
 
bool invalidate (bid_type bid)
 
request_ptr read (block_type *&block, bid_type bid)
 Reads block. If this block is cached block is not read but passed from the cache. More...
 

Protected Types

typedef write_pool< block_type > write_pool_type
 
typedef prefetch_pool< block_type > prefetch_pool_type
 

Protected Attributes

write_pool_typew_pool
 
prefetch_pool_typep_pool
 
bool delete_pools
 

Detailed Description

template<typename BlockType>
class read_write_pool< BlockType >

Implements dynamically resizable buffered writing and prefetched reading pool.

Constructor & Destructor Documentation

template<typename BlockType >
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
template<typename BlockType >
virtual read_write_pool< BlockType >::~read_write_pool ( )
inlinevirtual

Waits for completion of all ongoing requests and frees memory.

Member Function Documentation

template<typename BlockType >
bool 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

References prefetch_pool< BlockType >::hint().

Referenced by queue< ValTp, BlkSz, AllocStr, SzTp >::pop(), and queue< ValTp, BlkSz, AllocStr, SzTp >::push().

template<typename BlockType >
request_ptr 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

References prefetch_pool< BlockType >::read().

Referenced by queue< ValTp, BlkSz, AllocStr, SzTp >::pop().

template<typename BlockType >
void 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

References prefetch_pool< BlockType >::resize().

template<typename BlockType >
void 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

References write_pool< BlockType >::resize().

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

Returns number of blocks owned by the prefetch_pool.

References prefetch_pool< BlockType >::size().

Referenced by queue< ValTp, BlkSz, AllocStr, SzTp >::set_prefetch_aggr().

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

Returns number of blocks owned by the write_pool.

References write_pool< BlockType >::size().

template<typename BlockType >
block_type* 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.

References write_pool< BlockType >::steal().

Referenced by queue< ValTp, BlkSz, AllocStr, SzTp >::push().

template<typename BlockType >
request_ptr 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

References prefetch_pool< BlockType >::hint(), and write_pool< BlockType >::write().

Referenced by queue< ValTp, BlkSz, AllocStr, SzTp >::push().


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