• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List

request_queue_impl_qwqr.h

00001 /***************************************************************************
00002  *  include/stxxl/bits/io/request_queue_impl_qwqr.h
00003  *
00004  *  Part of the STXXL. See http://stxxl.sourceforge.net
00005  *
00006  *  Copyright (C) 2002 Roman Dementiev <dementiev@mpi-sb.mpg.de>
00007  *  Copyright (C) 2008 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
00008  *
00009  *  Distributed under the Boost Software License, Version 1.0.
00010  *  (See accompanying file LICENSE_1_0.txt or copy at
00011  *  http://www.boost.org/LICENSE_1_0.txt)
00012  **************************************************************************/
00013 
00014 #ifndef STXXL_IO_REQUEST_QUEUE_IMPL_QWQR_HEADER
00015 #define STXXL_IO_REQUEST_QUEUE_IMPL_QWQR_HEADER
00016 
00017 #include <list>
00018 
00019 #include <stxxl/bits/io/request_queue_impl_worker.h>
00020 #include <stxxl/bits/common/mutex.h>
00021 
00022 
00023 __STXXL_BEGIN_NAMESPACE
00024 
00027 
00028 class request_queue_impl_qwqr : public request_queue_impl_worker, public disk_queue
00029 {
00030 private:
00031     typedef request_queue_impl_qwqr self;
00032     typedef std::list<request_ptr> queue_type;
00033 
00034     mutex write_mutex;
00035     mutex read_mutex;
00036     queue_type write_queue;
00037     queue_type read_queue;
00038 
00039     state<thread_state> _thread_state;
00040     thread_type thread;
00041     semaphore sem;
00042 
00043     static const priority_op _priority_op = WRITE;
00044 
00045     static void * worker(void * arg);
00046 
00047 public:
00048     // \param n max number of requests simultaneously submitted to disk
00049     request_queue_impl_qwqr(int n = 1);
00050 
00051     // in a multi-threaded setup this does not work as intended
00052     // also there were race conditions possible
00053     // and actually an old value was never restored once a new one was set ...
00054     // so just disable it and all it's nice implications
00055     void set_priority_op(priority_op op)
00056     {
00057         //_priority_op = op;
00058         STXXL_UNUSED(op);
00059     }
00060     void add_request(request_ptr & req);
00061     bool cancel_request(request_ptr & req);
00062     ~request_queue_impl_qwqr();
00063 };
00064 
00066 
00067 __STXXL_END_NAMESPACE
00068 
00069 #endif // !STXXL_IO_REQUEST_QUEUE_IMPL_QWQR_HEADER
00070 // vim: et:ts=4:sw=4

Generated on Sun Oct 17 2010 06:13:44 for Stxxl by  doxygen 1.7.1