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

Implements dynamically resizable buffered writing pool. More...

#include <write_pool.h>

Inherits noncopyable.

Public Types

typedef BlockType block_type
 
typedef block_type::bid_type bid_type
 
typedef std::list< block_type * >
::iterator 
free_blocks_iterator
 
typedef std::list< busy_entry >
::iterator 
busy_blocks_iterator
 

Public Member Functions

 write_pool (unsigned_type init_size=1)
 Constructs pool. More...
 
void swap (write_pool &obj)
 
virtual ~write_pool ()
 Waits for completion of all ongoing write requests and frees memory. More...
 
unsigned_type size () const
 Returns number of owned blocks. 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 resize (unsigned_type new_size)
 Resizes size of the pool. More...
 
return request_ptr ()
 
bool has_request (bid_type bid)
 
std::pair< block_type
*, request_ptr
steal_request (bid_type bid)
 
void add (block_type *&block)
 

Protected Member Functions

void check_all_busy ()
 

Protected Attributes

std::list< block_type * > free_blocks
 
std::list< busy_entry > busy_blocks
 
unsigned_type free_blocks_size
 
unsigned_type busy_blocks_size
 

Detailed Description

template<class BlockType>
class write_pool< BlockType >

Implements dynamically resizable buffered writing pool.

Constructor & Destructor Documentation

template<class BlockType>
write_pool< BlockType >::write_pool ( unsigned_type  init_size = 1)
inlineexplicit

Constructs pool.

Parameters
init_sizeinitial number of blocks in the pool
template<class BlockType>
virtual write_pool< BlockType >::~write_pool ( )
inlinevirtual

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

Member Function Documentation

template<class BlockType>
void write_pool< BlockType >::resize ( unsigned_type  new_size)
inline

Resizes size of the pool.

Parameters
new_sizenew size of the pool after the call

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

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

template<class BlockType>
unsigned_type write_pool< BlockType >::size ( ) const
inline
template<class BlockType>
block_type* 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 >::size(), and wait_any().

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

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

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


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