Thrill  0.1
request_with_waiters.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * foxxll/io/request_with_waiters.hpp
3  *
4  * Part of FOXXLL. See http://foxxll.org
5  *
6  * Copyright (C) 2002 Roman Dementiev <[email protected]>
7  * Copyright (C) 2008 Andreas Beckmann <[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_WAITERS_HEADER
15 #define FOXXLL_IO_REQUEST_WITH_WAITERS_HEADER
16 
17 #include <mutex>
18 #include <set>
19 
21 #include <foxxll/io/request.hpp>
22 
23 namespace foxxll {
24 
25 //! \addtogroup foxxll_reqlayer
26 //! \{
27 
28 //! Request that is aware of threads waiting for it to complete.
30 {
31  std::mutex waiters_mutex_;
32  std::set<onoff_switch*> waiters_;
33 
34 protected:
35  bool add_waiter(onoff_switch* sw) final;
36  void delete_waiter(onoff_switch* sw) final;
37  void notify_waiters() final;
38 
39  //! returns number of waiters
40  size_t num_waiters();
41 
42 public:
44  const completion_handler& on_complete,
47  : request(on_complete, file, buffer, offset, bytes, op)
48  { }
49 };
50 
51 //! \}
52 
53 } // namespace foxxll
54 
55 #endif // !FOXXLL_IO_REQUEST_WITH_WAITERS_HEADER
56 
57 /**************************************************************************/
size_t num_waiters()
returns number of waiters
uint64_t offset_type
type for offsets within a file
void * buffer() const
Definition: request.hpp:96
read_or_write op() const
Definition: request.hpp:99
size_t size_type
type for block transfer sizes
bool add_waiter(onoff_switch *sw) final
FOXXLL library namespace
void delete_waiter(onoff_switch *sw) final
std::set< onoff_switch * > waiters_
Request object encapsulating basic properties like file and offset.
Definition: request.hpp:49
offset_type offset() const
Definition: request.hpp:97
Request that is aware of threads waiting for it to complete.
size_type bytes() const
Definition: request.hpp:98