STXXL  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
request_interface.h
Go to the documentation of this file.
1 /***************************************************************************
2  * include/stxxl/bits/io/request_interface.h
3  *
4  * Part of the STXXL. See http://stxxl.sourceforge.net
5  *
6  * Copyright (C) 2002 Roman Dementiev <[email protected]>
7  * Copyright (C) 2008, 2009, 2011 Andreas Beckmann <[email protected]>
8  * Copyright (C) 2009 Johannes Singler <[email protected]>
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_IO_REQUEST_INTERFACE_HEADER
16 #define STXXL_IO_REQUEST_INTERFACE_HEADER
17 
18 #include <ostream>
19 
20 #include <stxxl/bits/namespace.h>
21 #include <stxxl/bits/noncopyable.h>
23 
24 
26 
27 //! \addtogroup iolayer
28 //! \{
29 
30 class onoff_switch;
31 
32 //! Functional interface of a request.
33 //!
34 //! Since all library I/O operations are asynchronous,
35 //! one needs to keep track of their status:
36 //! e.g. whether an I/O operation completed or not.
38 {
39 public:
42  enum request_type { READ, WRITE };
43 
44 public:
45  virtual bool add_waiter(onoff_switch* sw) = 0;
46  virtual void delete_waiter(onoff_switch* sw) = 0;
47 
48 protected:
49  virtual void notify_waiters() = 0;
50 
51 public:
52  // HACK!
53  virtual void serve() = 0;
54 
55 protected:
56  virtual void completed() = 0;
57 
58 public:
59  //! Suspends calling thread until completion of the request.
60  virtual void wait(bool measure_time = true) = 0;
61 
62  //! Cancel a request.
63  //!
64  //! The request is canceled unless already being processed.
65  //! However, cancelation cannot be guaranteed.
66  //! Canceled requests must still be waited for in order to ensure correct operation.
67  //! If the request was canceled successfully, the completion handler will not be called.
68  //! \return \c true iff the request was canceled successfully
69  virtual bool cancel() = 0;
70 
71  //! Polls the status of the request.
72  //! \return \c true if request is completed, otherwise \c false
73  virtual bool poll() = 0;
74 
75  //! Identifies the type of I/O implementation.
76  //! \return pointer to null terminated string of characters, containing the name of I/O implementation
77  virtual const char * io_type() const = 0;
78 
79  //! Dumps properties of a request.
80  virtual std::ostream & print(std::ostream& out) const = 0;
81 
83  { }
84 };
85 
86 //! \}
87 
89 
90 #endif // !STXXL_IO_REQUEST_INTERFACE_HEADER
91 // vim: et:ts=4:sw=4
unsigned_type internal_size_type
Definition: types.h:69
#define STXXL_BEGIN_NAMESPACE
Definition: namespace.h:16
stxxl::internal_size_type size_type
Functional interface of a request.
uint64 external_size_type
Definition: types.h:70
stxxl::external_size_type offset_type
#define STXXL_END_NAMESPACE
Definition: namespace.h:17