GNU Radio 3.3.0 C++ API
gc_client_thread_info.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2007,2010 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License along
00018  * with this program; if not, write to the Free Software Foundation, Inc.,
00019  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00020  */
00021 #ifndef INCLUDED_GC_CLIENT_THREAD_INFO_H
00022 #define INCLUDED_GC_CLIENT_THREAD_INFO_H
00023 
00024 #include <boost/thread.hpp>
00025 #include <boost/utility.hpp>
00026 
00027 enum gc_ct_state {
00028   CT_NOT_WAITING,
00029   CT_WAIT_ALL,
00030   CT_WAIT_ANY,
00031 };
00032 
00033 /*
00034  * \brief per client-thread data used by gc_job_manager
00035  *
00036  * "Client threads" are any threads that invoke methods on
00037  * gc_job_manager.  We use pthread_set_specific to store a pointer to
00038  * one of these for each thread that comes our way.
00039  */
00040 class gc_client_thread_info : boost::noncopyable {
00041 public:
00042   gc_client_thread_info() :
00043     d_free(1), d_cond(), d_state(CT_NOT_WAITING),
00044     d_jobs_done(0), d_njobs_waiting_for(0),
00045     d_jobs_waiting_for(0){ }
00046 
00047   ~gc_client_thread_info() {
00048     d_free = 1;
00049     d_state = CT_NOT_WAITING;
00050     d_jobs_done = 0;
00051     d_njobs_waiting_for = 0;
00052     d_jobs_waiting_for = 0;
00053   }
00054 
00055   //! is this cti free? (1->free, 0->in use)
00056   uint32_t        d_free;
00057 
00058   //! which client info are we?
00059   uint16_t        d_client_id;
00060 
00061   //! hold this mutex to manipulate anything below here
00062   boost::mutex    d_mutex;
00063 
00064   //! signaled by event handler to wake client thread up
00065   boost::condition_variable d_cond;
00066 
00067   //! Is this client waiting?
00068   gc_ct_state     d_state;
00069   
00070   //! Jobs that have finished and not yet been waited for (bitvector)
00071   unsigned long  *d_jobs_done;
00072 
00073   //! # of jobs we're waiting for
00074   unsigned int    d_njobs_waiting_for;
00075 
00076   //! Jobs that client thread is waiting for
00077   gc_job_desc    **d_jobs_waiting_for;
00078 
00079 };
00080 
00081 #endif /* INCLUDED_GC_CLIENT_THREAD_INFO_H */