| 30 | } |
| 31 | |
| 32 | IProcessor::Status DelayedSource::prepare() |
| 33 | { |
| 34 | /// At first, wait for main output is needed and expand pipeline. |
| 35 | if (inputs.empty()) |
| 36 | { |
| 37 | auto & first_output = outputs.front(); |
| 38 | |
| 39 | /// If main output port was finished before callback was called, stop execution. |
| 40 | if (first_output.isFinished()) |
| 41 | { |
| 42 | for (auto & output : outputs) |
| 43 | output.finish(); |
| 44 | |
| 45 | return Status::Finished; |
| 46 | } |
| 47 | |
| 48 | if (!first_output.isNeeded()) |
| 49 | return Status::PortFull; |
| 50 | |
| 51 | /// Call creator callback to get processors. |
| 52 | if (processors.empty()) |
| 53 | return Status::Ready; |
| 54 | |
| 55 | return Status::UpdatePipeline; |
| 56 | } |
| 57 | |
| 58 | /// Process ports in order: main, totals, extremes |
| 59 | auto output = outputs.begin(); |
| 60 | for (auto input = inputs.begin(); input != inputs.end(); ++input, ++output) |
| 61 | { |
| 62 | if (output->isFinished()) |
| 63 | { |
| 64 | input->close(); |
| 65 | continue; |
| 66 | } |
| 67 | |
| 68 | if (!output->canPush()) |
| 69 | return Status::PortFull; |
| 70 | |
| 71 | if (input->isFinished()) |
| 72 | { |
| 73 | output->finish(); |
| 74 | continue; |
| 75 | } |
| 76 | |
| 77 | input->setNeeded(); |
| 78 | if (!input->hasData()) |
| 79 | return Status::NeedData; |
| 80 | |
| 81 | output->pushData(input->pullData(true)); |
| 82 | return Status::PortFull; |
| 83 | } |
| 84 | |
| 85 | return Status::Finished; |
| 86 | } |
| 87 | |
| 88 | /// Fix port from returned pipe. Create source_port if created or drop if source_port is null. |
| 89 | static void synchronizePorts(OutputPort *& pipe_port, OutputPort * source_port, SharedHeader header, Processors & processors) |
nothing calls this directly
no test coverage detected