Stxxl  1.4.0
mng/mng.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002  *  mng/mng.cpp
00003  *
00004  *  Part of the STXXL. See http://stxxl.sourceforge.net
00005  *
00006  *  Copyright (C) 2002-2004 Roman Dementiev <dementiev@mpi-sb.mpg.de>
00007  *  Copyright (C) 2008, 2010 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 #include <stxxl/bits/mng/mng.h>
00015 
00016 
00017 __STXXL_BEGIN_NAMESPACE
00018 
00019 block_manager::block_manager()
00020 {
00021     config * cfg = config::get_instance();
00022 
00023     ndisks = cfg->disks_number();
00024     disk_allocators = new DiskAllocator *[ndisks];
00025     disk_files = new file *[ndisks];
00026 
00027     for (unsigned i = 0; i < ndisks; ++i)
00028     {
00029         disk_files[i] = create_file(cfg->disk_io_impl(i),
00030                                     cfg->disk_path(i),
00031                                     file::CREAT | file::RDWR | file::DIRECT,
00032                                     i,          // physical_device_id
00033                                     i);         // allocator_id
00034         disk_allocators[i] = new DiskAllocator(disk_files[i], cfg->disk_size(i));
00035     }
00036 
00037     m_totalalloc = m_maxalloc = 0;
00038 }
00039 
00040 block_manager::~block_manager()
00041 {
00042     STXXL_VERBOSE1("Block manager: current alloc " << m_totalalloc << " maximum allocation " << m_maxalloc);
00043 
00044     STXXL_VERBOSE1("Block manager destructor");
00045     for (unsigned i = ndisks; i > 0; )
00046     {
00047         --i;
00048         delete disk_allocators[i];
00049         delete disk_files[i];
00050     }
00051     delete[] disk_allocators;
00052     delete[] disk_files;
00053 }
00054 
00055 __STXXL_END_NAMESPACE
00056 // vim: et:ts=4:sw=4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines