I'm basically using std::future and std:: promise in a way just opposite to how it was intended to be used(i.e what it seems to me).
It works, but there should be a less kludgy way to do the same thing.
Before yelling "Premature Optimization" note that I'd like to use a similar construct to play around with sorting algorithms.
So, adding the extra check at every iteration may not be good....though the asymptotic complexity won't change (afaik).
(After that feel free to say so )
void foo(std::promise<bool>& p)
std::future<bool> f= p.get_future();
while(i++) //This is the loop I want to kill ...
std::cout<<"Counted to :"<<i<<std::endl;
p.set_value(true); //...by sending a message or setting a flag from elsewhere/