I have a recursive function that I want to thread, using either windows threading or boost threading. I have examples for how to do threading both ways, but I am not sure how to implement either, into my function. Below is the example of my boost threading.
struct ThreadDemo {
ThreadDemo( int secs ) : secs_(secs) { }
void operator() (void) {
boost::xtime xt;
boost::xtime_get( &xt, boost::TIME_UTC );
xt.sec += secs_;
boost::thread::sleep( xt );
{
boost::mutex::scoped_lock lock(printing);
cout << "Thread ended..." << endl;
}
}
};
I am just not 100% sure on how it works, but if you guys could help me to understand it better, I could hopefully implement into my function on my own.
Well, what you have looks like a functor – I think you are confusing that with a thread.
To make a thread in boost (or windows, or pthreads), all you need a function.
Here is a great reference (It is the one I used when first learning Boost threads)
http://drdobbs.com/cpp/184401518