Stxxl  1.3.2
request_queue_impl_qwqr.h
1 /***************************************************************************
2  * include/stxxl/bits/io/request_queue_impl_qwqr.h
3  *
4  * Part of the STXXL. See http://stxxl.sourceforge.net
5  *
6  * Copyright (C) 2002 Roman Dementiev <[email protected]>
7  * Copyright (C) 2008, 2009 Andreas Beckmann <[email protected]>
8  * Copyright (C) 2009 Johannes Singler <[email protected]>
9  *
10  * Distributed under the Boost Software License, Version 1.0.
11  * (See accompanying file LICENSE_1_0.txt or copy at
12  * http://www.boost.org/LICENSE_1_0.txt)
13  **************************************************************************/
14 
15 #ifndef STXXL_IO_REQUEST_QUEUE_IMPL_QWQR_HEADER
16 #define STXXL_IO_REQUEST_QUEUE_IMPL_QWQR_HEADER
17 
18 #include <list>
19 
20 #include <stxxl/bits/io/request_queue_impl_worker.h>
21 #include <stxxl/bits/common/mutex.h>
22 
23 
24 __STXXL_BEGIN_NAMESPACE
25 
28 
29 class request_queue_impl_qwqr : public request_queue_impl_worker
30 {
31 private:
32  typedef request_queue_impl_qwqr self;
33  typedef std::list<request_ptr> queue_type;
34 
35  mutex write_mutex;
36  mutex read_mutex;
37  queue_type write_queue;
38  queue_type read_queue;
39 
40  state<thread_state> _thread_state;
41  thread_type thread;
42  semaphore sem;
43 
44  static const priority_op _priority_op = WRITE;
45 
46  static void * worker(void * arg);
47 
48 public:
49  // \param n max number of requests simultaneously submitted to disk
50  request_queue_impl_qwqr(int n = 1);
51 
52  // in a multi-threaded setup this does not work as intended
53  // also there were race conditions possible
54  // and actually an old value was never restored once a new one was set ...
55  // so just disable it and all it's nice implications
56  void set_priority_op(priority_op op)
57  {
58  //_priority_op = op;
59  STXXL_UNUSED(op);
60  }
61  void add_request(request_ptr & req);
62  bool cancel_request(request_ptr & req);
63  ~request_queue_impl_qwqr();
64 };
65 
67 
68 __STXXL_END_NAMESPACE
69 
70 #endif // !STXXL_IO_REQUEST_QUEUE_IMPL_QWQR_HEADER
71 // vim: et:ts=4:sw=4
Implemented as reference counting smart pointer.
Definition: request_ptr.h:34