1 /*************************************************************************** 2 * tests/mng/test_prefetch_pool.cpp 3 * 4 * Part of FOXXLL. See http://foxxll.org 5 * 6 * Copyright (C) 2003 Roman Dementiev <dementiev@mpi-sb.mpg.de> 7 * Copyright (C) 2009 Andreas Beckmann <beckmann@cs.uni-frankfurt.de> 8 * 9 * Distributed under the Boost Software License, Version 1.0. 10 * (See accompanying file LICENSE_1_0.txt or copy at 11 * http://www.boost.org/LICENSE_1_0.txt) 12 **************************************************************************/ 13 14 //! \example mng/test_prefetch_pool.cpp 15 16 #include <iostream> 17 18 #include <foxxll/mng.hpp> 19 #include <foxxll/mng/prefetch_pool.hpp> 20 21 #define BLOCK_SIZE (1024 * 512) 22 23 struct MyType 24 { 25 int integer; 26 char chars[5]; 27 }; 28 29 using block_type = foxxll::typed_block<BLOCK_SIZE, MyType>; 30 31 // forced instantiation 32 template class foxxll::prefetch_pool<block_type>; 33 main()34int main() 35 { 36 foxxll::prefetch_pool<block_type> pool(2); 37 pool.resize(10); 38 pool.resize(5); 39 40 block_type* blk = new block_type; 41 (*blk)[0].integer = 42; 42 block_type::bid_type bids[2]; 43 foxxll::block_manager::get_instance()->new_blocks(foxxll::single_disk(), bids, bids + 2); 44 blk->write(bids[0])->wait(); 45 blk->write(bids[1])->wait(); 46 47 pool.hint(bids[0]); 48 pool.read(blk, bids[0])->wait(); 49 pool.read(blk, bids[1])->wait(); 50 51 delete blk; 52 } 53 54 /**************************************************************************/ 55