summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJosh Blum2012-11-05 22:59:47 -0800
committerJosh Blum2012-11-05 22:59:47 -0800
commit37a863991f5e05035cce6738379de7a8ebc2b160 (patch)
treec7f2c7732074d69f1b3fe147f5fb32d92c34c9c8 /python
parented68f79a7a2e3c1bdbe0a2b4c5498ac29e431cce (diff)
downloadsandhi-37a863991f5e05035cce6738379de7a8ebc2b160.tar.gz
sandhi-37a863991f5e05035cce6738379de7a8ebc2b160.tar.bz2
sandhi-37a863991f5e05035cce6738379de7a8ebc2b160.zip
polish up work and notify api
There is a formal api to mark done, and IO failures. Notify topology was created for consistency. So far, there output fail is unimplemented, and input fail requires an additional check.
Diffstat (limited to 'python')
-rw-r--r--python/gras/GRAS_Block.i21
1 files changed, 11 insertions, 10 deletions
diff --git a/python/gras/GRAS_Block.i b/python/gras/GRAS_Block.i
index 9e917b4..ab92b26 100644
--- a/python/gras/GRAS_Block.i
+++ b/python/gras/GRAS_Block.i
@@ -26,7 +26,7 @@
%feature("nodirector") gras::BlockPython::propagate_tags;
%feature("nodirector") gras::BlockPython::start;
%feature("nodirector") gras::BlockPython::stop;
-%feature("nodirector") gras::BlockPython::check_topology;
+%feature("nodirector") gras::BlockPython::notify_topology;
%feature("nodirector") gras::BlockPython::work;
////////////////////////////////////////////////////////////////////////
@@ -137,15 +137,15 @@ struct BlockPython : Block
virtual bool _Py_stop(void) = 0;
- bool check_topology(int ninputs, int noutputs)
+ void notify_topology(const size_t num_inputs, const size_t num_outputs)
{
PyGILPhondler phil();
- return this->_Py_check_topology(ninputs, noutputs);
+ return this->_Py_notify_topology(num_inputs, num_outputs);
}
- virtual bool _Py_check_topology(int ninputs, int noutputs) = 0;
+ virtual void _Py_notify_topology(const size_t num_inputs, const size_t num_outputs) = 0;
- int work
+ void work
(
const InputItems &input_items,
const OutputItems &output_items
@@ -173,7 +173,7 @@ struct BlockPython : Block
IOPairVec _input_items;
IOPairVec _output_items;
- virtual int _Py_work
+ virtual void _Py_work
(
const IOPairVec &input_items,
const IOPairVec &output_items
@@ -247,14 +247,15 @@ class Block(BlockPython):
ndarray = pointer_to_ndarray(addr=addr, dtype=self.__out_sig[i], nitems=nitems, readonly=False)
output_arrays.append(ndarray)
- return self.work(input_arrays, output_arrays)
+ ret = self.work(input_arrays, output_arrays)
+ if ret is not None:
+ raise Exception, 'work return != None, did you call consume/produce?'
def work(self, *args):
print 'Implement Work!'
- return -1
- def _Py_check_topology(self, *args): return self.check_topology(*args)
- def check_topology(self, *args): return True
+ def _Py_notify_topology(self, *args): return self.notify_topology(*args)
+ def notify_topology(self, *args): return
def _Py_start(self): return self.start()
def start(self): return True