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

request_queue_impl_1q.h

00001 /***************************************************************************
00002  *  include/stxxl/bits/io/request_queue_impl_1q.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  *
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_1Q_HEADER
00015 #define STXXL_IO_REQUEST_QUEUE_IMPL_1Q_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_1q : public request_queue_impl_worker, public disk_queue
00029 {
00030 private:
00031     typedef request_queue_impl_1q self;
00032     typedef std::list<request_ptr> queue_type;
00033 
00034     mutex queue_mutex;
00035     queue_type queue;
00036 
00037     state<thread_state> _thread_state;
00038     thread_type thread;
00039     semaphore sem;
00040 
00041     static const priority_op _priority_op = WRITE;
00042 
00043     static void * worker(void * arg);
00044 
00045 public:
00046     // \param n max number of requests simultaneously submitted to disk
00047     request_queue_impl_1q(int n = 1);
00048 
00049     // in a multi-threaded setup this does not work as intended
00050     // also there were race conditions possible
00051     // and actually an old value was never restored once a new one was set ...
00052     // so just disable it and all it's nice implications
00053     void set_priority_op(priority_op op)
00054     {
00055         //_priority_op = op;
00056         STXXL_UNUSED(op);
00057     }
00058     void add_request(request_ptr & req);
00059     bool cancel_request(request_ptr & req);
00060     ~request_queue_impl_1q();
00061 };
00062 
00064 
00065 __STXXL_END_NAMESPACE
00066 
00067 #endif // !STXXL_IO_REQUEST_QUEUE_IMPL_1Q_HEADER
00068 // vim: et:ts=4:sw=4

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