summaryrefslogtreecommitdiff
path: root/gcell/lib/runtime/gc_client_thread_info.h
blob: e49c070975ef64bb7f297a43a34ce15841ff85f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* -*- c++ -*- */
/*
 * Copyright 2007,2010 Free Software Foundation, Inc.
 * 
 * This file is part of GNU Radio
 * 
 * GNU Radio is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 * 
 * GNU Radio is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
#ifndef INCLUDED_GC_CLIENT_THREAD_INFO_H
#define INCLUDED_GC_CLIENT_THREAD_INFO_H

#include <boost/thread.hpp>
#include <boost/utility.hpp>

enum gc_ct_state {
  CT_NOT_WAITING,
  CT_WAIT_ALL,
  CT_WAIT_ANY,
};

/*
 * \brief per client-thread data used by gc_job_manager
 *
 * "Client threads" are any threads that invoke methods on
 * gc_job_manager.  We use pthread_set_specific to store a pointer to
 * one of these for each thread that comes our way.
 */
class gc_client_thread_info : boost::noncopyable {
public:
  gc_client_thread_info() :
    d_free(1), d_cond(), d_state(CT_NOT_WAITING),
    d_jobs_done(0), d_njobs_waiting_for(0),
    d_jobs_waiting_for(0){ }

  ~gc_client_thread_info() {
    d_free = 1;
    d_state = CT_NOT_WAITING;
    d_jobs_done = 0;
    d_njobs_waiting_for = 0;
    d_jobs_waiting_for = 0;
  }

  //! is this cti free? (1->free, 0->in use)
  uint32_t	  d_free;

  //! which client info are we?
  uint16_t	  d_client_id;

  //! hold this mutex to manipulate anything below here
  boost::mutex	  d_mutex;

  //! signaled by event handler to wake client thread up
  boost::condition_variable d_cond;

  //! Is this client waiting?
  gc_ct_state	  d_state;
  
  //! Jobs that have finished and not yet been waited for (bitvector)
  unsigned long	 *d_jobs_done;

  //! # of jobs we're waiting for
  unsigned int    d_njobs_waiting_for;

  //! Jobs that client thread is waiting for
  gc_job_desc	 **d_jobs_waiting_for;

};

#endif /* INCLUDED_GC_CLIENT_THREAD_INFO_H */