~ubuntu-branches/ubuntu/trusty/gnuradio/trusty-updates

« back to all changes in this revision

Viewing changes to gnuradio-core/src/lib/runtime/gr_msg_queue.i

  • Committer: Package Import Robot
  • Author(s): A. Maitland Bottoms
  • Date: 2012-02-26 21:26:16 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120226212616-vsfkbi1158xshdql
Tags: 3.5.1-1
* new upstream version, re-packaged from scratch with modern tools
    closes: #642716, #645332, #394849, #616832, #590048, #642580,
    #647018, #557050, #559640, #631863
* CMake build

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- c++ -*- */
2
2
/*
3
 
 * Copyright 2005 Free Software Foundation, Inc.
 
3
 * Copyright 2005,2009,2010 Free Software Foundation, Inc.
4
4
 * 
5
5
 * This file is part of GNU Radio
6
6
 * 
32
32
 */
33
33
%ignore gr_msg_queue;
34
34
class gr_msg_queue : public gr_msg_handler {
35
 
  omni_mutex            d_mutex;
36
 
  omni_condition        d_cond;
37
 
  gr_message_sptr       d_head;
38
 
  gr_message_sptr       d_tail;
39
 
  int                   d_count;
40
 
 
41
35
public:
42
36
  gr_msg_queue(unsigned int limit);
43
37
  ~gr_msg_queue();
87
81
 * functions into the gr.msg_queue wrapper class, so that everything
88
82
 * appears normal.  (An evil laugh is heard in the distance...)
89
83
 */
 
84
#ifdef SWIGPYTHON
90
85
%inline %{
91
86
  gr_message_sptr gr_py_msg_queue__delete_head(gr_msg_queue_sptr q) {
92
87
    gr_message_sptr msg;
109
104
gr_msg_queue_sptr.insert_tail = gr_py_msg_queue__insert_tail
110
105
gr_msg_queue_sptr.handle = gr_py_msg_queue__insert_tail
111
106
%}
 
107
#endif  // SWIGPYTHON
 
108
 
 
109
/*
 
110
 * Similar trickery as above, only this time for Guile
 
111
 */
 
112
#ifdef SWIGGUILE
 
113
 
 
114
%{
 
115
  struct arg_holder {
 
116
    gr_msg_queue_sptr   q;
 
117
    gr_message_sptr     msg;
 
118
  };
 
119
 
 
120
  static void *
 
121
  insert_tail_shim(void *arg)
 
122
  {
 
123
    arg_holder *a = (arg_holder *)arg;
 
124
    a->q->insert_tail(a->msg);
 
125
    return 0;
 
126
  }
 
127
 
 
128
  static void *
 
129
  delete_head_shim(void *arg)
 
130
  {
 
131
    arg_holder *a = (arg_holder *)arg;
 
132
    a->msg = a->q->delete_head();
 
133
    return 0;
 
134
  }
 
135
%}
 
136
 
 
137
%inline %{
 
138
 
 
139
  // handle and insert_tail are equivalent
 
140
  static void
 
141
  handle(gr_msg_queue_sptr q, gr_message_sptr msg)
 
142
  {
 
143
    arg_holder  a;
 
144
    a.q = q;
 
145
    a.msg = msg;
 
146
    scm_without_guile(insert_tail_shim, (void *) &a);
 
147
  }
 
148
 
 
149
  static void
 
150
  insert_tail(gr_msg_queue_sptr q, gr_message_sptr msg)
 
151
  {
 
152
    arg_holder  a;
 
153
    a.q = q;
 
154
    a.msg = msg;
 
155
    scm_without_guile(insert_tail_shim, (void *) &a);
 
156
  }
 
157
 
 
158
  static gr_message_sptr
 
159
  delete_head(gr_msg_queue_sptr q)
 
160
  {
 
161
    arg_holder  a;
 
162
    a.q = q;
 
163
    scm_without_guile(delete_head_shim, (void *) &a);
 
164
    return a.msg;
 
165
  }
 
166
%}
 
167
 
 
168
#endif  // SWIGGUILE