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