Stxxl  1.4.0
mng/test_prefetch_pool.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002  *  mng/test_prefetch_pool.cpp
00003  *
00004  *  Part of the STXXL. See http://stxxl.sourceforge.net
00005  *
00006  *  Copyright (C) 2003 Roman Dementiev <dementiev@mpi-sb.mpg.de>
00007  *  Copyright (C) 2009 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
00008  *
00009  *  Distributed under the Boost Software License, Version 1.0.
00010  *  (See accompanying file LICENSE_1_0.txt or copy at
00011  *  http://www.boost.org/LICENSE_1_0.txt)
00012  **************************************************************************/
00013 
00014 //! \example mng/test_prefetch_pool.cpp
00015 
00016 #include <iostream>
00017 #include <stxxl/mng>
00018 #include <stxxl/bits/mng/prefetch_pool.h>
00019 
00020 #define BLOCK_SIZE (1024 * 512)
00021 
00022 struct MyType
00023 {
00024     int integer;
00025     char chars[5];
00026 };
00027 
00028 typedef stxxl::typed_block<BLOCK_SIZE, MyType> block_type;
00029 
00030 int main()
00031 {
00032     stxxl::prefetch_pool<block_type> pool(2);
00033     pool.resize(10);
00034     pool.resize(5);
00035 
00036     block_type * blk = new block_type;
00037     (*blk)[0].integer = 42;
00038     block_type::bid_type bids[2];
00039     stxxl::block_manager::get_instance()->new_blocks(stxxl::single_disk(), bids, bids + 2);
00040     blk->write(bids[0])->wait();
00041     blk->write(bids[1])->wait();
00042 
00043     pool.hint(bids[0]);
00044     pool.read(blk, bids[0])->wait();
00045     pool.read(blk, bids[1])->wait();
00046 
00047     delete blk;
00048 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines