This is a sample use case of the execution stream. It should not be used directly by the factory. Instead, it is recommended to use it from the IHardware instance given some possible restrictions. This example is purely a test of the proof-of-concept.
#include <atomic>
#include <cynq/cynq.hpp>
#include <iostream>
#include <thread>
volatile std::atomic_int num{0};
std::this_thread::sleep_for(std::chrono::seconds(1));
std::cout << "num: " << num.load() << std::endl;
num++;
}
int main(int, char **) {
auto type = cynq::IExecutionGraph::Type::STREAM;
for (uint i = 0; i < 5; ++i) {
stream->Add(func);
}
stream->Sync(2);
std::cout << "Synchronised w.r.t. the third" << std::endl;
stream->Sync();
std::cout << "Synchronised w.r.t. the last" << std::endl;
stream->Add(func);
stream->Sync();
std::cout << "Synchronised w.r.t. the last" << std::endl;
return 0;
}
std::function< Status()> Function
Underlying type for the auxiliar functions.
Definition: execution-graph.hpp:67
static std::shared_ptr< IExecutionGraph > Create(const IExecutionGraph::Type type, const std::shared_ptr< ExecutionGraphParameters > params)
Factory method to create a new implementation.
Definition: execution-graph.cpp:13
Structure to define the return characteristics of each function.
Definition: status.hpp:19