Stxxl 1.2.1
|
00001 /*************************************************************************** 00002 * include/stxxl/bits/io/wfs_file.h 00003 * 00004 * Windows file system file base 00005 * 00006 * Part of the STXXL. See http://stxxl.sourceforge.net 00007 * 00008 * Copyright (C) 2005 Roman Dementiev <dementiev@ira.uka.de> 00009 * 00010 * Distributed under the Boost Software License, Version 1.0. 00011 * (See accompanying file LICENSE_1_0.txt or copy at 00012 * http://www.boost.org/LICENSE_1_0.txt) 00013 **************************************************************************/ 00014 00015 #ifndef STXXL_WFSFILEBASE_HEADER 00016 #define STXXL_WFSFILEBASE_HEADER 00017 00018 #ifdef STXXL_BOOST_CONFIG 00019 #include <boost/config.hpp> 00020 #endif 00021 00022 #ifdef BOOST_MSVC 00023 00024 #include <stxxl/bits/io/iobase.h> 00025 00026 00027 __STXXL_BEGIN_NAMESPACE 00028 00031 00032 class wfs_request_base; 00033 00035 class wfs_file_base : public file 00036 { 00037 protected: 00038 HANDLE file_des; // file descriptor 00039 int mode_; // open mode 00040 wfs_file_base(const std::string & filename, int mode, int disk); 00041 00042 public: 00043 HANDLE get_file_des() const; 00044 ~wfs_file_base(); 00045 stxxl::int64 size(); 00046 void set_size(stxxl::int64 newsize); 00047 void lock(); 00048 }; 00049 00051 class wfs_request_base : public request 00052 { 00053 friend class wfs_file_base; 00054 00055 protected: 00056 // states of request 00057 enum { OP = 0, DONE = 1, READY2DIE = 2 }; 00058 // OP - operating, DONE - request served, 00059 // READY2DIE - can be destroyed 00060 /* 00061 wfs_file_base *file; 00062 void *buffer; 00063 stxxl::int64 offset; 00064 size_t bytes; 00065 request_type type; 00066 */ 00067 00068 state _state; 00069 mutex waiters_mutex; 00070 std::set<onoff_switch *> waiters; 00071 00072 wfs_request_base( 00073 wfs_file_base * f, 00074 void * buf, 00075 stxxl::int64 off, 00076 size_t b, 00077 request_type t, 00078 completion_handler on_cmpl); 00079 00080 bool add_waiter(onoff_switch * sw); 00081 void delete_waiter(onoff_switch * sw); 00082 int nwaiters(); // returns number of waiters 00083 void check_aligning(); 00084 00085 public: 00086 virtual ~wfs_request_base(); 00087 void wait(); 00088 bool poll(); 00089 const char * io_type(); 00090 }; 00091 00093 00094 __STXXL_END_NAMESPACE 00095 00096 #endif // #ifdef BOOST_MSVC 00097 00098 #endif // !STXXL_WFSFILEBASE_HEADER