Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
linuxaio_file.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * foxxll/io/linuxaio_file.cpp
3  *
4  * Part of FOXXLL. See http://foxxll.org
5  *
6  * Copyright (C) 2011 Johannes Singler <[email protected]>
7  *
8  * Distributed under the Boost Software License, Version 1.0.
9  * (See accompanying file LICENSE_1_0.txt or copy at
10  * http://www.boost.org/LICENSE_1_0.txt)
11  **************************************************************************/
12 
14 
15 #if FOXXLL_HAVE_LINUXAIO_FILE
16 
19 
20 namespace foxxll {
21 
22 request_ptr linuxaio_file::aread(
23  void* buffer, offset_type offset, size_type bytes,
24  const completion_handler& on_complete)
25 {
26  request_ptr req = tlx::make_counting<linuxaio_request>(
27  on_complete, this, buffer, offset, bytes, request::READ
28  );
29 
30  disk_queues::get_instance()->add_request(req, get_queue_id());
31 
32  return req;
33 }
34 
35 request_ptr linuxaio_file::awrite(
36  void* buffer, offset_type offset, size_type bytes,
37  const completion_handler& on_complete)
38 {
39  request_ptr req = tlx::make_counting<linuxaio_request>(
40  on_complete, this, buffer, offset, bytes, request::WRITE
41  );
42 
43  disk_queues::get_instance()->add_request(req, get_queue_id());
44 
45  return req;
46 }
47 
48 void linuxaio_file::serve(void* buffer, offset_type offset, size_type bytes,
50 {
51  // req need not be an linuxaio_request
52  if (op == request::READ)
53  aread(buffer, offset, bytes)->wait();
54  else
55  awrite(buffer, offset, bytes)->wait();
56 }
57 
58 const char* linuxaio_file::io_type() const
59 {
60  return "linuxaio";
61 }
62 
63 } // namespace foxxll
64 
65 #endif // #if FOXXLL_HAVE_LINUXAIO_FILE
66 
67 /**************************************************************************/
tlx::counting_ptr< request > request_ptr
A reference counting pointer for request.
Definition: request.hpp:43
tlx::delegate< void(request *r, bool success)> completion_handler
completion handler
Definition: request.hpp:46
static instance_pointer get_instance()
Definition: singleton.hpp:44
static const size_t bytes
number of bytes in uint_pair
Definition: uint_types.hpp:75
void add_request(request_ptr &req, disk_id_type disk)
Definition: disk_queues.cpp:60