Stxxl  1.2.1
wfs_file.h
1 /***************************************************************************
2  * include/stxxl/bits/io/wfs_file.h
3  *
4  * Windows file system file base
5  *
6  * Part of the STXXL. See http://stxxl.sourceforge.net
7  *
8  * Copyright (C) 2005 Roman Dementiev <dementiev@ira.uka.de>
9  *
10  * Distributed under the Boost Software License, Version 1.0.
11  * (See accompanying file LICENSE_1_0.txt or copy at
12  * http://www.boost.org/LICENSE_1_0.txt)
13  **************************************************************************/
14 
15 #ifndef STXXL_WFSFILEBASE_HEADER
16 #define STXXL_WFSFILEBASE_HEADER
17 
18 #ifdef STXXL_BOOST_CONFIG
19  #include <boost/config.hpp>
20 #endif
21 
22 #ifdef BOOST_MSVC
23 
24 #include <stxxl/bits/io/iobase.h>
25 
26 
27 __STXXL_BEGIN_NAMESPACE
28 
31 
32 class wfs_request_base;
33 
35 class wfs_file_base : public file
36 {
37 protected:
38  HANDLE file_des; // file descriptor
39  int mode_; // open mode
40  wfs_file_base(const std::string & filename, int mode, int disk);
41 
42 public:
43  HANDLE get_file_des() const;
44  ~wfs_file_base();
45  stxxl::int64 size();
46  void set_size(stxxl::int64 newsize);
47  void lock();
48 };
49 
51 class wfs_request_base : public request
52 {
53  friend class wfs_file_base;
54 
55 protected:
56  // states of request
57  enum { OP = 0, DONE = 1, READY2DIE = 2 };
58  // OP - operating, DONE - request served,
59  // READY2DIE - can be destroyed
60  /*
61  wfs_file_base *file;
62  void *buffer;
63  stxxl::int64 offset;
64  size_t bytes;
65  request_type type;
66  */
67 
68  state _state;
69  mutex waiters_mutex;
70  std::set<onoff_switch *> waiters;
71 
72  wfs_request_base(
73  wfs_file_base * f,
74  void * buf,
75  stxxl::int64 off,
76  size_t b,
77  request_type t,
78  completion_handler on_cmpl);
79 
80  bool add_waiter(onoff_switch * sw);
81  void delete_waiter(onoff_switch * sw);
82  int nwaiters(); // returns number of waiters
83  void check_aligning();
84 
85 public:
86  virtual ~wfs_request_base();
87  void wait();
88  bool poll();
89  const char * io_type();
90 };
91 
93 
94 __STXXL_END_NAMESPACE
95 
96 #endif // #ifdef BOOST_MSVC
97 
98 #endif // !STXXL_WFSFILEBASE_HEADER