Stxxl  1.4.0
include/stxxl/bits/io/request_queue_impl_worker.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  *  include/stxxl/bits/io/request_queue_impl_worker.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_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 
00035 //! \addtogroup iolayer
00036 //! \{
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 
00054 //! \}
00055 
00056 __STXXL_END_NAMESPACE
00057 
00058 #endif // !STXXL_IO_REQUEST_QUEUE_IMPL_WORKER_HEADER
00059 // vim: et:ts=4:sw=4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines