STXXL  1.4.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  * lib/io/linuxaio_file.cpp
3  *
4  * Part of the STXXL. See http://stxxl.sourceforge.net
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 STXXL_HAVE_LINUXAIO_FILE
16 
19 
21 
22 request_ptr linuxaio_file::aread(
23  void* buffer,
24  offset_type pos,
26  const completion_handler& on_cmpl)
27 {
28  request_ptr req(new linuxaio_request(on_cmpl, this, buffer, pos, bytes, request::READ));
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,
37  offset_type pos,
39  const completion_handler& on_cmpl)
40 {
41  request_ptr req(new linuxaio_request(on_cmpl, this, buffer, pos, bytes, request::WRITE));
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 (type == 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 
64 
65 #endif // #if STXXL_HAVE_LINUXAIO_FILE
66 // vim: et:ts=4:sw=4
Completion handler class (Loki-style).
request::size_type size_type
the size of a request
Definition: file.h:62
virtual void wait(bool measure_time=true)=0
Suspends calling thread until completion of the request.
#define STXXL_BEGIN_NAMESPACE
Definition: namespace.h:16
static const size_t bytes
number of bytes in uint_pair
Definition: uint_types.h:96
request::offset_type offset_type
the offset of a request, also the size of the file
Definition: file.h:60
Request for an linuxaio_file.
#define STXXL_END_NAMESPACE
Definition: namespace.h:17