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