GNU Radio 3.7.0 C++ API
thread_group.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright (C) 2001-2003 William E. Kempf
00004  * Copyright (C) 2007 Anthony Williams
00005  * Copyright 2008,2009 Free Software Foundation, Inc.
00006  *
00007  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
00008  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00009  */
00010 
00011 /*
00012  * This was extracted from Boost 1.35.0 and fixed.
00013  */
00014 
00015 #ifndef INCLUDED_THREAD_GROUP_H
00016 #define INCLUDED_THREAD_GROUP_H
00017 
00018 #include <gnuradio/api.h>
00019 #include <gnuradio/thread/thread.h>
00020 #include <boost/utility.hpp>
00021 #include <boost/thread/shared_mutex.hpp>
00022 #include <boost/function.hpp>
00023 
00024 namespace gr {
00025   namespace thread {
00026 
00027     class GR_RUNTIME_API thread_group : public boost::noncopyable
00028     {
00029     public:
00030       thread_group();
00031       ~thread_group();
00032 
00033       boost::thread* create_thread(const boost::function0<void>& threadfunc);
00034       void add_thread(boost::thread* thrd);
00035       void remove_thread(boost::thread* thrd);
00036       void join_all();
00037       void interrupt_all();
00038       size_t size() const;
00039 
00040     private:
00041       std::list<boost::thread*> m_threads;
00042       mutable boost::shared_mutex m_mutex;
00043     };
00044 
00045   } /* namespace thread */
00046 } /* namespace gr */
00047 
00048 #endif /* INCLUDED_THREAD_GROUP_H */