Stxxl  1.3.2
request_with_state.h
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_H_
15 #define STXXL_IO__REQUEST_WITH_STATE_H_
16 
17 #include <stxxl/bits/common/state.h>
18 #include <stxxl/bits/io/request.h>
19 #include <stxxl/bits/io/request_with_waiters.h>
20 
21 
22 __STXXL_BEGIN_NAMESPACE
23 
26 
29 {
30 protected:
33  enum request_state { OP = 0, DONE = 1, READY2DIE = 2 };
34 
35  state<request_state> _state;
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(on_cmpl, f, buf, off, b, t),
46  _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 
57 
58 __STXXL_END_NAMESPACE
59 
60 #endif // !STXXL_IO__REQUEST_WITH_STATE_H_
61 // vim: et:ts=4:sw=4
bool poll()
Polls the status of the request.
Definition: request_with_state.cpp:66
Defines interface of file.
Definition: file.h:90
void wait(bool measure_time=true)
Suspends calling thread until completion of the request.
Definition: request_with_state.cpp:35
request_state
Definition: request_with_state.h:33
Request with basic properties like file and offset.
Definition: request.h:39
Completion handler class (Loki-style)
Definition: completion_handler.h:63
Request that is aware of threads waiting for it to complete.
Definition: request_with_waiters.h:30
Request with completion state.
Definition: request_with_state.h:28
bool cancel()
Cancel a request.
Definition: request_with_state.cpp:46