STXXL  1.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stxxl::grow_shrink_stack2< StackConfig > Class Template Reference

Detailed Description

template<class StackConfig>
class stxxl::grow_shrink_stack2< StackConfig >

Efficient implementation that uses prefetching and overlapping using (shared) buffers pools.

Warning
This is a single buffer stack! Each direction change (push() followed by pop() or vice versa) may cause one I/O.

Definition at line 540 of file stack.h.

+ Inheritance diagram for stxxl::grow_shrink_stack2< StackConfig >:
+ Collaboration diagram for stxxl::grow_shrink_stack2< StackConfig >:

Public Types

enum  { blocks_per_page = cfg::blocks_per_page, block_size = cfg::block_size }
 
typedef cfg::alloc_strategy alloc_strategy_type
 
typedef BID< block_sizebid_type
 
typedef typed_block
< block_size, value_type
block_type
 type of block used in disk-memory transfers More...
 
typedef StackConfig cfg
 
typedef cfg::size_type size_type
 type for sizes (64-bit) More...
 
typedef cfg::value_type value_type
 type of the elements stored in the stack More...
 

Public Member Functions

Constructors/Destructors
 grow_shrink_stack2 (pool_type &pool_, unsigned_type prefetch_aggressiveness=0)
 Default constructor: creates empty stack. The stack will use the read_write_pool for prefetching and buffered writing. More...
 
 grow_shrink_stack2 (prefetch_pool< block_type > &p_pool_, write_pool< block_type > &w_pool_, unsigned_type prefetch_aggressiveness=0)
 Default constructor: creates empty stack. The stack will use the pair of prefetch_pool and write_pool for prefetching and buffered writing. This constructor is deprecated in favor of the read_write_pool constructor. More...
 
virtual ~grow_shrink_stack2 ()
 
Accessor Functions
void swap (grow_shrink_stack2 &obj)
 
void push (const value_type &val)
 Inserts an element at the top of the stack. Postconditions: size() is incremented by 1, and top() is the inserted element. More...
 
value_typetop ()
 Return mutable reference to the element at the top of the stack. Precondition: stack is not empty(). More...
 
const value_typetop () const
 Return constant reference to the element at the top of the stack. Precondition: stack is not empty(). More...
 
void pop ()
 Removes the element at the top of the stack. Precondition: stack is not empty(). Postcondition: size() is decremented. More...
 
Capacity
size_type size () const
 Returns the number of elements contained in the stack. More...
 
bool empty () const
 Returns true if the stack is empty. More...
 
Miscellaneous
void set_prefetch_aggr (unsigned_type new_p)
 Sets level of prefetch aggressiveness (number of blocks from the prefetch pool used for prefetching). More...
 
unsigned_type get_prefetch_aggr () const
 Returns number of blocks used for prefetching. More...
 

Private Types

typedef read_write_pool
< block_type
pool_type
 

Private Member Functions

void rehint ()
 hint the last pref_aggr external blocks. More...
 
- Private Member Functions inherited from stxxl::noncopyable
 noncopyable ()
 

Private Attributes

alloc_strategy_type alloc_strategy
 
std::vector< bid_typebids
 
block_typecache
 
unsigned_type cache_offset
 
size_type m_size
 
pool_typeowned_pool
 
pool_typepool
 
unsigned_type pref_aggr
 

Member Typedef Documentation

template<class StackConfig>
typedef cfg::alloc_strategy stxxl::grow_shrink_stack2< StackConfig >::alloc_strategy_type

Definition at line 546 of file stack.h.

template<class StackConfig>
typedef BID<block_size> stxxl::grow_shrink_stack2< StackConfig >::bid_type

Definition at line 556 of file stack.h.

template<class StackConfig>
typedef typed_block<block_size, value_type> stxxl::grow_shrink_stack2< StackConfig >::block_type

type of block used in disk-memory transfers

Definition at line 555 of file stack.h.

template<class StackConfig>
typedef StackConfig stxxl::grow_shrink_stack2< StackConfig >::cfg

Definition at line 543 of file stack.h.

template<class StackConfig>
typedef read_write_pool<block_type> stxxl::grow_shrink_stack2< StackConfig >::pool_type
private

Definition at line 559 of file stack.h.

template<class StackConfig>
typedef cfg::size_type stxxl::grow_shrink_stack2< StackConfig >::size_type

type for sizes (64-bit)

Definition at line 548 of file stack.h.

template<class StackConfig>
typedef cfg::value_type stxxl::grow_shrink_stack2< StackConfig >::value_type

type of the elements stored in the stack

Definition at line 545 of file stack.h.

Member Enumeration Documentation

template<class StackConfig>
anonymous enum
Enumerator
blocks_per_page 
block_size 

Definition at line 549 of file stack.h.

Constructor & Destructor Documentation

template<class StackConfig>
stxxl::grow_shrink_stack2< StackConfig >::grow_shrink_stack2 ( pool_type pool_,
unsigned_type  prefetch_aggressiveness = 0 
)
inline

Default constructor: creates empty stack. The stack will use the read_write_pool for prefetching and buffered writing.

Parameters
pool_block write/prefetch pool
prefetch_aggressivenessnumber of blocks that will be used from prefetch pool

Definition at line 578 of file stack.h.

References STXXL_VERBOSE2.

template<class StackConfig>
stxxl::grow_shrink_stack2< StackConfig >::grow_shrink_stack2 ( prefetch_pool< block_type > &  p_pool_,
write_pool< block_type > &  w_pool_,
unsigned_type  prefetch_aggressiveness = 0 
)
inline

Default constructor: creates empty stack. The stack will use the pair of prefetch_pool and write_pool for prefetching and buffered writing. This constructor is deprecated in favor of the read_write_pool constructor.

Parameters
p_pool_prefetch pool, that will be used for block prefetching
w_pool_write pool, that will be used for block writing
prefetch_aggressivenessnumber of blocks that will be used from prefetch pool

Definition at line 602 of file stack.h.

References STXXL_VERBOSE2.

template<class StackConfig>
virtual stxxl::grow_shrink_stack2< StackConfig >::~grow_shrink_stack2 ( )
inlinevirtual

Definition at line 635 of file stack.h.

References stxxl::STXXL_MAX(), and STXXL_VERBOSE2.

Member Function Documentation

template<class StackConfig>
bool stxxl::grow_shrink_stack2< StackConfig >::empty ( ) const
inline

Returns true if the stack is empty.

Definition at line 679 of file stack.h.

template<class StackConfig>
unsigned_type stxxl::grow_shrink_stack2< StackConfig >::get_prefetch_aggr ( ) const
inline

Returns number of blocks used for prefetching.

Definition at line 791 of file stack.h.

template<class StackConfig>
void stxxl::grow_shrink_stack2< StackConfig >::pop ( )
inline

Removes the element at the top of the stack. Precondition: stack is not empty(). Postcondition: size() is decremented.

Definition at line 744 of file stack.h.

References STXXL_VERBOSE2, STXXL_VERBOSE3, and UNLIKELY.

template<class StackConfig>
void stxxl::grow_shrink_stack2< StackConfig >::push ( const value_type val)
inline

Inserts an element at the top of the stack. Postconditions: size() is incremented by 1, and top() is the inserted element.

Definition at line 691 of file stack.h.

References stxxl::STXXL_MAX(), STXXL_VERBOSE2, STXXL_VERBOSE3, and UNLIKELY.

template<class StackConfig>
void stxxl::grow_shrink_stack2< StackConfig >::rehint ( )
inlineprivate

hint the last pref_aggr external blocks.

Definition at line 800 of file stack.h.

References stxxl::STXXL_MAX().

template<class StackConfig>
void stxxl::grow_shrink_stack2< StackConfig >::set_prefetch_aggr ( unsigned_type  new_p)
inline

Sets level of prefetch aggressiveness (number of blocks from the prefetch pool used for prefetching).

Parameters
new_pnew value for the prefetch aggressiveness

Definition at line 774 of file stack.h.

References stxxl::STXXL_MAX().

template<class StackConfig>
size_type stxxl::grow_shrink_stack2< StackConfig >::size ( ) const
inline

Returns the number of elements contained in the stack.

Definition at line 674 of file stack.h.

template<class StackConfig>
value_type& stxxl::grow_shrink_stack2< StackConfig >::top ( )
inline

Return mutable reference to the element at the top of the stack. Precondition: stack is not empty().

Definition at line 724 of file stack.h.

template<class StackConfig>
const value_type& stxxl::grow_shrink_stack2< StackConfig >::top ( ) const
inline

Return constant reference to the element at the top of the stack. Precondition: stack is not empty().

Definition at line 734 of file stack.h.

Member Data Documentation

template<class StackConfig>
alloc_strategy_type stxxl::grow_shrink_stack2< StackConfig >::alloc_strategy
private

Definition at line 565 of file stack.h.

Referenced by stxxl::grow_shrink_stack2< StackConfig >::swap().

template<class StackConfig>
std::vector<bid_type> stxxl::grow_shrink_stack2< StackConfig >::bids
private

Definition at line 564 of file stack.h.

Referenced by stxxl::grow_shrink_stack2< StackConfig >::swap().

template<class StackConfig>
block_type* stxxl::grow_shrink_stack2< StackConfig >::cache
private

Definition at line 563 of file stack.h.

Referenced by stxxl::grow_shrink_stack2< StackConfig >::swap().

template<class StackConfig>
unsigned_type stxxl::grow_shrink_stack2< StackConfig >::cache_offset
private

Definition at line 562 of file stack.h.

Referenced by stxxl::grow_shrink_stack2< StackConfig >::swap().

template<class StackConfig>
size_type stxxl::grow_shrink_stack2< StackConfig >::m_size
private

Definition at line 561 of file stack.h.

Referenced by stxxl::grow_shrink_stack2< StackConfig >::swap().

template<class StackConfig>
pool_type* stxxl::grow_shrink_stack2< StackConfig >::owned_pool
private

Definition at line 567 of file stack.h.

Referenced by stxxl::grow_shrink_stack2< StackConfig >::swap().

template<class StackConfig>
pool_type* stxxl::grow_shrink_stack2< StackConfig >::pool
private

Definition at line 568 of file stack.h.

Referenced by stxxl::grow_shrink_stack2< StackConfig >::swap().

template<class StackConfig>
unsigned_type stxxl::grow_shrink_stack2< StackConfig >::pref_aggr
private

Definition at line 566 of file stack.h.

Referenced by stxxl::grow_shrink_stack2< StackConfig >::swap().


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