Thrill  0.1
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/core.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 public:
48  linuxaio_request(
49  const completion_handler& on_complete,
50  file* file, void* buffer, offset_type offset, size_type bytes,
51  const read_or_write& op)
52  : request_with_state(on_complete, file, buffer, offset, bytes, op)
53  {
54  assert(dynamic_cast<linuxaio_file*>(file));
55  TLX_LOG << "linuxaio_request[" << this << "]"
56  << " linuxaio_request"
57  << "(file=" << file << " buffer=" << buffer
58  << " offset=" << offset << " bytes=" << bytes
59  << " op=" << op << ")";
60  }
61 
62  iocb * fill_control_block();
63  bool cancel() final;
64  bool cancel_aio(linuxaio_queue* queue);
65  void completed(bool posted, bool canceled);
66  void completed(bool canceled) { completed(true, canceled); }
67 };
68 
69 //! \}
70 
71 } // namespace foxxll
72 
73 #endif // #if FOXXLL_HAVE_LINUXAIO_FILE
74 
75 #endif // !FOXXLL_IO_LINUXAIO_REQUEST_HEADER
76 
77 /**************************************************************************/
tlx::delegate< void(request *r, bool success)> completion_handler
completion handler
Definition: request.hpp:46
FOXXLL library namespace
static constexpr bool debug
static const size_t bytes
number of bytes in uint_pair
Definition: uint_types.hpp:75
#define TLX_LOG
Default logging method: output if the local debug variable is true.
Definition: core.hpp:141