STXXL  1.4.1
 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 
25 
26 //! \addtogroup reqlayer
27 //! \{
28 
29 class onoff_switch;
30 
31 //! Functional interface of a request.
32 //!
33 //! Since all library I/O operations are asynchronous,
34 //! one needs to keep track of their status:
35 //! e.g. whether an I/O operation completed or not.
37 {
38 public:
41  enum request_type { READ, WRITE };
42 
43 public:
44  virtual bool add_waiter(onoff_switch* sw) = 0;
45  virtual void delete_waiter(onoff_switch* sw) = 0;
46 
47 protected:
48  virtual void notify_waiters() = 0;
49 
50 protected:
51  virtual void completed(bool canceled) = 0;
52 
53 public:
54  //! Suspends calling thread until completion of the request.
55  virtual void wait(bool measure_time = true) = 0;
56 
57  //! Cancel a request.
58  //!
59  //! The request is canceled unless already being processed.
60  //! However, cancelation cannot be guaranteed.
61  //! Canceled requests must still be waited for in order to ensure correct operation.
62  //! If the request was canceled successfully, the completion handler will not be called.
63  //! \return \c true iff the request was canceled successfully
64  virtual bool cancel() = 0;
65 
66  //! Polls the status of the request.
67  //! \return \c true if request is completed, otherwise \c false
68  virtual bool poll() = 0;
69 
70  //! Identifies the type of I/O implementation.
71  //! \return pointer to null terminated string of characters, containing the name of I/O implementation
72  virtual const char * io_type() const = 0;
73 
74  //! Dumps properties of a request.
75  virtual std::ostream & print(std::ostream& out) const = 0;
76 
78  { }
79 };
80 
81 //! \}
82 
84 
85 #endif // !STXXL_IO_REQUEST_INTERFACE_HEADER
86 // vim: et:ts=4:sw=4
unsigned_type internal_size_type
Definition: types.h:66
#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:67
stxxl::external_size_type offset_type
#define STXXL_END_NAMESPACE
Definition: namespace.h:17