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