Stxxl  1.3.2
request_queue_impl_1q.h
1 /***************************************************************************
2  * include/stxxl/bits/io/request_queue_impl_1q.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_1Q_HEADER
16 #define STXXL_IO_REQUEST_QUEUE_IMPL_1Q_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_1q : public request_queue_impl_worker
30 {
31 private:
32  typedef request_queue_impl_1q self;
33  typedef std::list<request_ptr> queue_type;
34 
35  mutex queue_mutex;
36  queue_type queue;
37 
38  state<thread_state> _thread_state;
39  thread_type thread;
40  semaphore sem;
41 
42  static const priority_op _priority_op = WRITE;
43 
44  static void * worker(void * arg);
45 
46 public:
47  // \param n max number of requests simultaneously submitted to disk
48  request_queue_impl_1q(int n = 1);
49 
50  // in a multi-threaded setup this does not work as intended
51  // also there were race conditions possible
52  // and actually an old value was never restored once a new one was set ...
53  // so just disable it and all it's nice implications
54  void set_priority_op(priority_op op)
55  {
56  //_priority_op = op;
57  STXXL_UNUSED(op);
58  }
59  void add_request(request_ptr & req);
60  bool cancel_request(request_ptr & req);
61  ~request_queue_impl_1q();
62 };
63 
65 
66 __STXXL_END_NAMESPACE
67 
68 #endif // !STXXL_IO_REQUEST_QUEUE_IMPL_1Q_HEADER
69 // vim: et:ts=4:sw=4
External FIFO queue container.
Definition: queue.h:51
Implemented as reference counting smart pointer.
Definition: request_ptr.h:34