13 #ifndef STXXL_MNG_READ_WRITE_POOL_H
14 #define STXXL_MNG_READ_WRITE_POOL_H
16 #include <stxxl/bits/mng/write_pool.h>
17 #include <stxxl/bits/mng/prefetch_pool.h>
20 __STXXL_BEGIN_NAMESPACE
27 template <
typename BlockType>
31 typedef BlockType block_type;
32 typedef typename block_type::bid_type bid_type;
33 typedef unsigned_type size_type;
47 explicit read_write_pool(size_type init_size_prefetch = 1, size_type init_size_write = 1) :
54 _STXXL_DEPRECATED(
read_write_pool(prefetch_pool_type & p_pool, write_pool_type & w_pool)) :
55 w_pool(&w_pool), p_pool(&p_pool), delete_pools(false)
60 std::swap(w_pool, obj.w_pool);
61 std::swap(p_pool, obj.p_pool);
62 std::swap(delete_pools, obj.delete_pools);
108 if (p_pool->invalidate(bid))
109 p_pool->
hint(bid, *w_pool);
118 return w_pool->
steal();
121 void add(block_type * & block)
137 return p_pool->
hint(bid, *w_pool);
140 bool invalidate(bid_type bid)
142 return p_pool->invalidate(bid);
153 return p_pool->
read(block, bid, *w_pool);
159 __STXXL_END_NAMESPACE
164 template <
class BlockType>
165 void swap(stxxl::read_write_pool<BlockType> & a,
166 stxxl::read_write_pool<BlockType> & b)
172 #endif // !STXXL_MNG_READ_WRITE_POOL_H
bool hint(bid_type bid)
Gives a hint for prefetching a block.
Definition: prefetch_pool.h:121
request_ptr write(block_type *&block, bid_type bid)
Passes a block to the pool for writing.
Definition: write_pool.h:117
Implements dynamically resizable prefetching pool.
Definition: prefetch_pool.h:34
Implements dynamically resizable buffered writing pool.
Definition: write_pool.h:36
Implements dynamically resizable buffered writing and prefetched reading pool.
Definition: read_write_pool.h:28
void resize_write(size_type new_size)
Resizes size of the pool.
Definition: read_write_pool.h:82
void resize(unsigned_type new_size)
Resizes size of the pool.
Definition: write_pool.h:171
unsigned_type resize(unsigned_type new_size)
Resizes size of the pool.
Definition: prefetch_pool.h:261
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. ...
Definition: prefetch_pool.h:203
bool hint(bid_type bid)
Gives a hint for prefetching a block.
Definition: read_write_pool.h:135
block_type * steal()
Take out a block from the pool.
Definition: write_pool.h:141
void resize_prefetch(size_type new_size)
Resizes size of the pool.
Definition: read_write_pool.h:89
unsigned_type size() const
Returns number of owned blocks.
Definition: write_pool.h:109
Implemented as reference counting smart pointer.
Definition: request_ptr.h:34
unsigned_type size() const
Returns number of owned blocks.
Definition: prefetch_pool.h:112
read_write_pool(size_type init_size_prefetch=1, size_type init_size_write=1)
Constructs pool.
Definition: read_write_pool.h:47
request_ptr write(block_type *&block, bid_type bid)
Passes a block to the pool for writing.
Definition: read_write_pool.h:102
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. ...
Definition: read_write_pool.h:151
virtual ~read_write_pool()
Waits for completion of all ongoing requests and frees memory.
Definition: read_write_pool.h:66
size_type size_prefetch() const
Returns number of blocks owned by the prefetch_pool.
Definition: read_write_pool.h:78
block_type * steal()
Take out a block from the pool.
Definition: read_write_pool.h:116
size_type size_write() const
Returns number of blocks owned by the write_pool.
Definition: read_write_pool.h:75