Stxxl 1.2.1
|
00001 /*************************************************************************** 00002 * include/stxxl/bits/io/mmap_file.h 00003 * 00004 * Part of the STXXL. See http://stxxl.sourceforge.net 00005 * 00006 * Copyright (C) 2002 Roman Dementiev <dementiev@mpi-sb.mpg.de> 00007 * 00008 * Distributed under the Boost Software License, Version 1.0. 00009 * (See accompanying file LICENSE_1_0.txt or copy at 00010 * http://www.boost.org/LICENSE_1_0.txt) 00011 **************************************************************************/ 00012 00013 #ifndef STXXL_MMAP_FILE_HEADER 00014 #define STXXL_MMAP_FILE_HEADER 00015 00016 #ifdef STXXL_BOOST_CONFIG 00017 #include <boost/config.hpp> 00018 #endif 00019 00020 #ifndef BOOST_MSVC 00021 // mmap call does not exist in Windows 00022 00023 #include <sys/mman.h> 00024 00025 #include <stxxl/bits/io/ufs_file.h> 00026 00027 00028 __STXXL_BEGIN_NAMESPACE 00029 00035 00037 class mmap_file : public ufs_file_base 00038 { 00039 public: 00044 inline mmap_file(const std::string & filename, int mode, int disk = -1) : 00045 ufs_file_base(filename, mode, disk) 00046 { } 00047 request_ptr aread( 00048 void * buffer, 00049 stxxl::int64 pos, 00050 size_t bytes, 00051 completion_handler on_cmpl); 00052 request_ptr awrite( 00053 void * buffer, 00054 stxxl::int64 pos, 00055 size_t bytes, 00056 completion_handler on_cmpl); 00057 }; 00058 00060 class mmap_request : public ufs_request_base 00061 { 00062 friend class mmap_file; 00063 00064 protected: 00065 inline mmap_request(mmap_file * f, 00066 void * buf, stxxl::int64 off, size_t b, 00067 request_type t, 00068 completion_handler on_cmpl) : 00069 ufs_request_base(f, buf, off, b, t, on_cmpl) 00070 { } 00071 void serve(); 00072 00073 public: 00074 inline const char * io_type() 00075 { 00076 return "mmap"; 00077 } 00078 }; 00079 00081 00082 __STXXL_END_NAMESPACE 00083 00084 #endif // #ifndef BOOST_MSVC 00085 00086 #endif // !STXXL_MMAP_FILE_HEADER