Boost logo

Boost Users :

From: Paul Grenyer (pjgrenyer_at_[hidden])
Date: 2003-07-31 15:25:44


On Thu, 2003-07-31 at 20:44, Mark Sizer wrote:

Hi Mark

> I just did this, it's remarkably easy. I then ported the system to Linux
> from Windows with no problems at all. Boost Threads rock. That being said...

Great! :-)

> Be very careful about confusing object lifetime with thread lifetime.
> The relationship is murky, at best. I can start a thread on a stack
> based object. When that object goes out of scope, the thread does not
> stop. I can start a thread on a heap based object, when the thread
> terminates, the object is not deleted.

> That being said, I use the method you describe. Just make sure your
> object doesn't go out of scope or get deleted.

Yes. I'd already got this far. :-)

At the moment we use a system that involves inheriting from an object
which creates the thread and overriding the method that is run in the
thread. We have a variable number of threads in this particular
application, which are stored in a container. This is easy because there
is only one object to store.

After looking at the boost thread stuff the only idea I've had so far is
to store a structure in the container which has two members. One is the
thread object the other is the thread. However, this idea doesn't feel
right at the moment and I'm going to have to give it some more thought.
Any suggestions would be greatly appreciated.

> I found the synchronization stuff strange, at first. Now I love it, it's
> much less error prone than critical sections or mutexes.

Thanks for the pointers! I'll have a closer look at this stuff tomorrow
at work.

-- 
Regards
Paul
Paul Grenyer
Email: pjgrenyer_at_[hidden]
Web: www.paulgrenyer.co.uk
EvaneScence: http://www.evanescence.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net