What is "the right thing"?
You don't HAVE to join(). The creating thread will just keep going if you don't. If you join, it waits.
If you're passing ownership (e.g. delete responsibility) across thread boundaries, you have to be careful, but that doesn't have much to do with join().
After starting the thread, you can use a condtional in the creator to wait for the thread to "get going" and accept ownership, sort of a "started()" rather than an "ended()", like join(). Or you can flip it around and have the started thread wait on the conditional whilst the creator thread continues to use what will eventually be given to the
I'm afraid this thread was started by one of my "senior moments". When
reading ~thread() and join(), I flipped a bit and "saw" join() handled
m_joinable == true and ~thread() handled m_joinable == false. THAT's why I
thought join() had to be called. Your post caused me to go back and read it
again. Now I'm *REALLY* embarrassed.
Thanks for getting me started down the right track.
"Mark Sizer"
Is that at all helpful?
- Mark
dick.bridges@tais.com wrote:
I need to spawn worker threads that simply perform a task and exit. All the examples I can find seem to use join() to cleanup the thread
resources
from another thread. Isn't there some way to declare worker threads so that they "do the right thing" as they exit the thread function?
TIA
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/