1#pragma once
2
3#include <Processors/IProcessor.h>
4
5
6namespace DB
7{
8
9/// Look for first Ready or Async processor by depth-first search in needed input ports and full output ports.
10/// NOTE: Pipeline must not have cycles.
11//template <typename Visit>
12//void traverse(IProcessor & processor, Visit && visit)
13//{
14// IProcessor::Status status = visit(processor);
15//
16// if (status == IProcessor::Status::Ready || status == IProcessor::Status::Async)
17// return;
18//
19// if (status == IProcessor::Status::NeedData)
20// for (auto & input : processor.getInputs())
21// if (input.isNeeded() && !input.hasData())
22// traverse(input.getOutputPort().getProcessor(), std::forward<Visit>(visit));
23//
24// if (status == IProcessor::Status::PortFull)
25// for (auto & output : processor.getOutputs())
26// if (output.hasData())
27// traverse(output.getInputPort().getProcessor(), std::forward<Visit>(visit));
28//}
29
30}
31