A simple pipeline implemented with C++
This project implements a multi-threaded pipeline processing system, where multiple pipes can be added, and the pipeline can be started and stopped as needed.
You can just transfer the header and source file to your project and start using it. Or you can build it into a library. To build it into a library, run these commands in a build directory (e.g. build/) inside your project directory:
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
Then the library files will be generated in the build directory (in our example build/).
pip::Pipeline pipeline(
3,
[]() { std::cout << "ctor\n"; return new pip::PipelineElement(); },
[](const pip::PipelineElement* _elem) { std::cout << "fdtor\n"; delete _elem; });
pipeline.AddPipe([](pip::PipelineElement* _pipElem)
{
if (_pipElem == nullptr)
return _pipElem;
std::this_thread::sleep_for(std::chrono::seconds(5));
std::cout << "first\n";
return _pipElem;
});
pipeline.AddPipe([](pip::PipelineElement* _pipElem)
{
if (_pipElem == nullptr)
return _pipElem;
std::this_thread::sleep_for(std::chrono::seconds(5));
std::cout << "second\n";
return _pipElem;
});
pipeline.AddPipe([](pip::PipelineElement* _pipElem)
{
if (_pipElem == nullptr)
return _pipElem;
std::this_thread::sleep_for(std::chrono::seconds(5));
std::cout << "third\n";
return _pipElem;
});
pipeline.AddPipe([](pip::PipelineElement* _pipElem)
{
if (_pipElem == nullptr)
return _pipElem;
std::this_thread::sleep_for(std::chrono::seconds(5));
std::cout << "forth\n";
return _pipElem;
});
pipeline.Run();
- Fork it (https://github.com/kebritam/pipeline)
- Create your feature branch (
git checkout -b feature/featureName
) - Commit your changes (
git commit -am 'Add your commit message'
) - Push to the branch (
git push origin feature/featureName
) - Create a new Pull Request