Stxxl
1.4.0
|
00001 /*************************************************************************** 00002 * io/request_queue_impl_worker.cpp 00003 * 00004 * Part of the STXXL. See http://stxxl.sourceforge.net 00005 * 00006 * Copyright (C) 2002-2005 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 #include <stxxl/bits/io/request_queue_impl_worker.h> 00016 #include <stxxl/bits/io/request.h> 00017 00018 #ifdef STXXL_BOOST_THREADS // Use Portable Boost threads 00019 #include <boost/bind.hpp> 00020 #endif 00021 00022 00023 __STXXL_BEGIN_NAMESPACE 00024 00025 void request_queue_impl_worker::start_thread(void * (*worker)(void *), void * arg, thread_type & t, state<thread_state> & s) 00026 #ifdef STXXL_BOOST_THREADS 00027 #endif 00028 { 00029 assert(s() == NOT_RUNNING); 00030 #ifdef STXXL_BOOST_THREADS 00031 t = new boost::thread(boost::bind(worker, arg)); 00032 #else 00033 check_pthread_call(pthread_create(&t, NULL, worker, arg)); 00034 #endif 00035 s.set_to(RUNNING); 00036 } 00037 00038 void request_queue_impl_worker::stop_thread(thread_type & t, state<thread_state> & s, semaphore & sem) 00039 { 00040 assert(s() == RUNNING); 00041 s.set_to(TERMINATING); 00042 sem++; 00043 #ifdef STXXL_BOOST_THREADS 00044 t->join(); 00045 delete t; 00046 t = NULL; 00047 #else 00048 check_pthread_call(pthread_join(t, NULL)); 00049 #endif 00050 s.set_to(NOT_RUNNING); 00051 } 00052 00053 __STXXL_END_NAMESPACE 00054 // vim: et:ts=4:sw=4