In an effort to make the MetaSharp pipelines more powerful I’m about to add the concepts of stages and connectors. I’ve been thinking about it a bit and I drew up some diagrams to help me express how the pattern should work.
At a high level it’s pretty simple, for every pipeline there are multiple stages and for each stage there are multiple steps. Each stage has 1 or many input connectors and 1 or many output connectors, which connects to the next stage of the pipeline.
With this in mind there are four possible types of stages, defined by their input and output connectors. Stages must be chained together with matching input and output connections. You want multiple types because there are certain types of operations that are simply not possible to do simultaneously but there are other types that are completely isolated and are perfectly acceptable to run asynchronously.
Many to Many
For each type of input a complete inner pipeline of steps is created. Meaning each input value from a previous stage will be processed by the same steps. Each inner pipeline will run asynchronously and should not communicate between each other. The stage will complete when all steps have completed running.
1 to 1
This type of stage will accept one input value and produce one output value. It will create exactly one chain of steps and execute synchronously.
1 to Many
This type of stage will accept one input value and have exactly one chain of steps but will produce many output values.
Many to One
This type of stage will accept many values and run them all through exactly one chain of steps.
From this I should be able to make any type of compilation pipeline imaginable. For example a typical pipeline might be something like this:
- Parse files
- Combine AST
- Resolve References
- Generate Assembly
In which case you might end up with the following stages:
- M:M, Parse files all at once
- M:1, Combine the ASTs into one tree.
- 1:1, Resolve and transform the tree.
- 1:1, Transform into IL
You could also imagine that last step transforming into multiple objects or multiple files or something like that quite easily. Also the good news is that I think this shouldn’t actually be that complicated. The pipeline simply deals with connecting stages and each stage has a very simple strategy for processing the steps. The real work will lie in the implementing the stages but even then each stage is completely modular and singularly focused.
You must log in to post a comment.