Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
request_with_state.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * foxxll/io/request_with_state.hpp
3  *
4  * Part of FOXXLL. See http://foxxll.org
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 FOXXLL_IO_REQUEST_WITH_STATE_HEADER
15 #define FOXXLL_IO_REQUEST_WITH_STATE_HEADER
16 
18 #include <foxxll/io/request.hpp>
20 
21 namespace foxxll {
22 
23 //! \addtogroup foxxll_reqlayer
24 //! \{
25 
26 //! Request with completion shared_state.
28 {
29  constexpr static bool debug = false;
30 
31 protected:
32  //! states of request.
33  //! OP - operating, DONE - request served, READY2DIE - can be destroyed
34  enum request_state { OP = 0, DONE = 1, READY2DIE = 2 };
35 
37 
38 protected:
40  const completion_handler& on_complete,
43  : request_with_waiters(on_complete, file, buffer, offset, bytes, op),
44  state_(OP)
45  { }
46 
47 public:
48  virtual ~request_with_state();
49  void wait(bool measure_time = true) final;
50  bool poll() final;
51  bool cancel() override;
52 
53 protected:
54  void completed(bool canceled) override;
55 };
56 
57 //! \}
58 
59 } // namespace foxxll
60 
61 #endif // !FOXXLL_IO_REQUEST_WITH_STATE_HEADER
62 
63 /**************************************************************************/
Request with completion shared_state.
void * buffer() const
Definition: request.hpp:96
uint64_t offset_type
type for offsets within a file
bool cancel() override
Cancel a request.
size_t size_type
type for block transfer sizes
read_or_write op() const
Definition: request.hpp:99
request_with_state(const completion_handler &on_complete, file *file, void *buffer, offset_type offset, size_type bytes, read_or_write op)
void completed(bool canceled) override
size_type bytes() const
Definition: request.hpp:98
offset_type offset() const
Definition: request.hpp:97
shared_state< request_state > state_
static constexpr bool debug
void wait(bool measure_time=true) final
Suspends calling thread until completion of the request.
Request that is aware of threads waiting for it to complete.