00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef STXXL_IO_REQUEST_QUEUE_IMPL_WORKER_HEADER
00016 #define STXXL_IO_REQUEST_QUEUE_IMPL_WORKER_HEADER
00017
00018 #ifdef STXXL_BOOST_CONFIG
00019 #include <boost/config.hpp>
00020 #endif
00021
00022 #ifdef STXXL_BOOST_THREADS // Use Portable Boost threads
00023 #include <boost/thread/thread.hpp>
00024 #else
00025 #include <pthread.h>
00026 #endif
00027
00028 #include <stxxl/bits/io/request_queue.h>
00029 #include <stxxl/bits/common/semaphore.h>
00030 #include <stxxl/bits/common/state.h>
00031
00032
00033 __STXXL_BEGIN_NAMESPACE
00034
00037
00038 class request_queue_impl_worker : public request_queue
00039 {
00040 protected:
00041 enum thread_state { NOT_RUNNING, RUNNING, TERMINATING, TERMINATE = TERMINATING };
00042
00043 #ifdef STXXL_BOOST_THREADS
00044 typedef boost::thread * thread_type;
00045 #else
00046 typedef pthread_t thread_type;
00047 #endif
00048
00049 protected:
00050 void start_thread(void * (*worker)(void *), void * arg, thread_type & t, state<thread_state> & s);
00051 void stop_thread(thread_type & t, state<thread_state> & s, semaphore & sem);
00052 };
00053
00055
00056 __STXXL_END_NAMESPACE
00057
00058 #endif // !STXXL_IO_REQUEST_QUEUE_IMPL_WORKER_HEADER
00059