Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
linuxaio_request.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * foxxll/io/linuxaio_request.hpp
3  *
4  * Part of FOXXLL. See http://foxxll.org
5  *
6  * Copyright (C) 2011 Johannes Singler <[email protected]>
7  * Copyright (C) 2014 Timo Bingmann <[email protected]>
8  *
9  * Distributed under the Boost Software License, Version 1.0.
10  * (See accompanying file LICENSE_1_0.txt or copy at
11  * http://www.boost.org/LICENSE_1_0.txt)
12  **************************************************************************/
13 
14 #ifndef FOXXLL_IO_LINUXAIO_REQUEST_HEADER
15 #define FOXXLL_IO_LINUXAIO_REQUEST_HEADER
16 
18 
19 #if FOXXLL_HAVE_LINUXAIO_FILE
20 
21 #include <linux/aio_abi.h>
22 
23 #include <tlx/logger.hpp>
24 
26 
27 namespace foxxll {
28 
29 //! \addtogroup foxxll_reqlayer
30 //! \{
31 
32 // forward declarations
33 class linuxaio_queue;
34 
35 //! Request for an linuxaio_file.
36 class linuxaio_request : public request_with_state
37 {
38  constexpr static bool debug = false;
39 
40  template <class base_file_type>
41  friend class fileperblock_file;
42 
43  //! control block of async request
44  iocb cb_;
45  double time_posted_;
46 
47  void fill_control_block();
48 
49 public:
50  linuxaio_request(
51  const completion_handler& on_complete,
52  file* file, void* buffer, offset_type offset, size_type bytes,
53  const read_or_write& op)
54  : request_with_state(on_complete, file, buffer, offset, bytes, op)
55  {
56  assert(dynamic_cast<linuxaio_file*>(file));
57  LOG << "linuxaio_request[" << this << "]" <<
58  " linuxaio_request" <<
59  "(file=" << file << " buffer=" << buffer <<
60  " offset=" << offset << " bytes=" << bytes <<
61  " op=" << op << ")";
62  }
63 
64  bool post();
65  bool cancel() final;
66  bool cancel_aio(linuxaio_queue* queue);
67  void completed(bool posted, bool canceled);
68  void completed(bool canceled) { completed(true, canceled); }
69 };
70 
71 //! \}
72 
73 } // namespace foxxll
74 
75 #endif // #if FOXXLL_HAVE_LINUXAIO_FILE
76 
77 #endif // !FOXXLL_IO_LINUXAIO_REQUEST_HEADER
78 
79 /**************************************************************************/
tlx::delegate< void(request *r, bool success)> completion_handler
completion handler
Definition: request.hpp:46
static constexpr bool debug
static const size_t bytes
number of bytes in uint_pair
Definition: uint_types.hpp:75
#define LOG
Default logging method: output if the local debug variable is true.
Definition: logger.hpp:141