2 # Copyright 2004 Free Software Foundation, Inc.
4 # This file is part of GNU Radio
6 # GNU Radio is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3, or (at your option)
11 # GNU Radio is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Radio; see the file COPYING. If not, write to
18 # the Free Software Foundation, Inc., 51 Franklin Street,
19 # Boston, MA 02110-1301, USA.
22 from gnuradio.gr.exceptions import *
23 from gnuradio_swig_python import single_threaded_scheduler, sts_pyrun
24 import gr_threading as _threading
25 #import threading as _threading
27 class scheduler_thread(_threading.Thread):
28 def __init__(self, sts):
29 _threading.Thread.__init__(self)
32 # Invoke the single threaded scheduler's run method
34 # Note that we're in a new thread, and that sts_pyrun
35 # releases the global interpreter lock. This has the
36 # effect of evaluating the graph in parallel to the
37 # main line control code.
41 class scheduler(object):
42 def __init__(self, fg):
43 graphs = fg.partition_graph(fg.blocks)
44 # print "@@@ # graphs = %d" % (len(graphs))
49 list_of_blocks = [x.block() for x in g]
50 sts = single_threaded_scheduler(list_of_blocks)
51 thread = scheduler_thread(sts)
53 self.state.append((sts, thread))
56 for (sts, thread) in self.state:
60 for (sts, thread) in self.state:
65 for (sts, thread) in self.state:
69 if not thread.isAlive():