How to combine multiple functions in a DAG form at runtime

I have several classes where each subclass is an Operator. The operator has several inputs and outputs of various types: image, number, string. Each subclass implements a run () method that performs the computation. Now I would like to create a container for these Operators in order to make the larger Operators out of the simple ones. The container needs to be as efficient as possible, which is why I'm planning on using streams. I found an example in the Boost graph library that allows me to compute the order in which I should perform the computation: http://www.boost.org/doc/libs/1_49_0/libs/graph/doc/file_dependency_example.htmlbut I think there might be an even better way to do this: each operator can wait in a blocked state until all of their inputs are ready. It would be nice if the container would subclass Operator, allowing you to recursively combine them. I have a feeling this is a famous design pattern.

+3


source to share


2 answers


I found a design pattern that matches my description: a composite pattern .



A composite template describes that a group of objects should be treated the same as a single instance of an object.

0


source


Maybe you can use a TBB flow graph?



http://software.intel.com/en-us/blogs/2011/09/08/the-intel-threading-building-blocks-flow-graph-is-now-fully-supported/

0


source







All Articles