STXXL  1.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
request_with_state.h
Go to the documentation of this file.
1 /***************************************************************************
2  * include/stxxl/bits/io/request_with_state.h
3  *
4  * Part of the STXXL. See http://stxxl.sourceforge.net
5  *
6  * Copyright (C) 2008 Andreas Beckmann <[email protected]>
7  * Copyright (C) 2009 Johannes Singler <[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 STXXL_IO_REQUEST_WITH_STATE_HEADER
15 #define STXXL_IO_REQUEST_WITH_STATE_HEADER
16 
18 #include <stxxl/bits/io/request.h>
20 #include <stxxl/bits/namespace.h>
21 
23 
24 //! \addtogroup reqlayer
25 //! \{
26 
27 //! Request with completion state.
29 {
30 protected:
31  //! states of request
32  //! OP - operating, DONE - request served, READY2DIE - can be destroyed
33  enum request_state { OP = 0, DONE = 1, READY2DIE = 2 };
34 
36 
37 protected:
39  const completion_handler& on_cmpl,
40  file* f,
41  void* buf,
42  offset_type off,
43  size_type b,
44  request_type t)
45  : request_with_waiters(on_cmpl, f, buf, off, b, t),
46  m_state(OP)
47  { }
48 
49 public:
50  virtual ~request_with_state();
51  void wait(bool measure_time = true);
52  bool poll();
53  bool cancel();
54 
55 protected:
56  void completed(bool canceled);
57 };
58 
59 //! \}
60 
62 
63 #endif // !STXXL_IO_REQUEST_WITH_STATE_HEADER
64 // vim: et:ts=4:sw=4
Completion handler class (Loki-style).
state< request_state > m_state
Request with completion state.
Request that is aware of threads waiting for it to complete.
request_with_state(const completion_handler &on_cmpl, file *f, void *buf, offset_type off, size_type b, request_type t)
Defines interface of file.
Definition: file.h:56
#define STXXL_BEGIN_NAMESPACE
Definition: namespace.h:16
stxxl::internal_size_type size_type
stxxl::external_size_type offset_type
request_state
states of request OP - operating, DONE - request served, READY2DIE - can be destroyed ...
#define STXXL_END_NAMESPACE
Definition: namespace.h:17