Stxxl  1.3.2
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
block_prefetcher< block_type, bid_iterator_type > Class Template Reference

Encapsulates asynchronous prefetching engine. More...

#include <block_prefetcher.h>

Collaboration diagram for block_prefetcher< block_type, bid_iterator_type >:
Collaboration graph
[legend]

Public Member Functions

 block_prefetcher (bid_iterator_type _cons_begin, bid_iterator_type _cons_end, int_type *_pref_seq, int_type _prefetch_buf_size, completion_handler do_after_fetch=default_completion_handler())
 Constructs an object and immediately starts prefetching. More...
 
block_type * pull_block ()
 Pulls next unconsumed block from the consumption sequence. More...
 
bool block_consumed (block_type *&buffer)
 Exchanges buffers between prefetcher and application. More...
 
bool empty () const
 
unsigned_type pos () const
 
 ~block_prefetcher ()
 Frees used memory. More...
 

Protected Member Functions

block_type * wait (int_type iblock)
 

Protected Attributes

bid_iterator_type consume_seq_begin
 
bid_iterator_type consume_seq_end
 
unsigned_type seq_length
 
int_type * prefetch_seq
 
unsigned_type nextread
 
unsigned_type nextconsume
 
const int_type nreadblocks
 
block_type * read_buffers
 
request_ptrread_reqs
 
bid_type * read_bids
 
onoff_switch * completed
 
int_type * pref_buffer
 
completion_handler do_after_fetch
 

Detailed Description

template<typename block_type, typename bid_iterator_type>
class block_prefetcher< block_type, bid_iterator_type >

Encapsulates asynchronous prefetching engine.

block_prefetcher overlaps I/Os with consumption of read data. Utilizes optimal asynchronous prefetch scheduling (by Peter Sanders et.al.)

Constructor & Destructor Documentation

template<typename block_type , typename bid_iterator_type >
block_prefetcher< block_type, bid_iterator_type >::block_prefetcher ( bid_iterator_type  _cons_begin,
bid_iterator_type  _cons_end,
int_type *  _pref_seq,
int_type  _prefetch_buf_size,
completion_handler  do_after_fetch = default_completion_handler() 
)
inline

Constructs an object and immediately starts prefetching.

Parameters
_cons_beginbid_iterator pointing to the bid of the first block to be consumed
_cons_endbid_iterator pointing to the bid of the ( last + 1 ) block of consumption sequence
_pref_seqgives the prefetch order, is a pointer to the integer array that contains the indices of the blocks in the consumption sequence
_prefetch_buf_sizeamount of prefetch buffers to use
template<typename block_type , typename bid_iterator_type >
block_prefetcher< block_type, bid_iterator_type >::~block_prefetcher ( )
inline

Frees used memory.

References request_interface::wait().

Member Function Documentation

template<typename block_type , typename bid_iterator_type >
bool block_prefetcher< block_type, bid_iterator_type >::block_consumed ( block_type *&  buffer)
inline

Exchanges buffers between prefetcher and application.

Parameters
bufferpointer to the consumed buffer. After call if return value is true buffer contains valid pointer to the next unconsumed prefetched buffer.
Remarks
parameter buffer must be value returned by pull_block() or block_consumed() methods
Returns
false if there are no blocks to prefetch left, true if consumption sequence is not emptied

References request_interface::wait().

Referenced by buf_istream< BlkTp_, BIDIteratorTp_ >::operator++(), and buf_istream< BlkTp_, BIDIteratorTp_ >::operator>>().

template<typename block_type , typename bid_iterator_type >
block_type* block_prefetcher< block_type, bid_iterator_type >::pull_block ( )
inline

Pulls next unconsumed block from the consumption sequence.

Returns
Pointer to the already prefetched block from the internal buffer pool

Referenced by buf_istream< BlkTp_, BIDIteratorTp_ >::buf_istream().


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