I'm currently trying to work with some image processing.
I'm using a function that streams the camera captions with an infinite while loop.
I just wanted to know, if it was possible to make the captions a return value of the function. I've tried to use "return" but it immediately kills the task.
In other words, make a function constantly have a return value by being called just once.
Thanks for your time, any reference would be of big help!
If a function returns a value then it finishes executing and must be called again to restart, and a function cannot send data back to the caller without returning.
Maybe what you want is for the function to continue running while a different function is also running and processing the data that was previously obtained. That's what threads are for. You can use them to execute multiple functions concurrently (i.e. "at the same time").
template<class Callback>
some_value work(Callback callback)
{
while (true)
{
// if some result available
callback(/* pass the data to the caller*/)
if(some condition)
return some value;
}
}