Boost logo

Boost Users :

Subject: [Boost-users] "Simple" graceful stop of boost thread
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2013-04-10 19:00:35


Hello,

I know this is possible, just don't have all the templates at the ready.
Graceful way of stopping a boost worker thread from running.

I am familiar with C# .NET threading, I can fairly simply signal an
AutoResetEvent, for instance, and wait a nominal period for it to be set.

Afterwards, this tells the thread to stop what it's doing at an opportune
moment. Meanwhile the parent thread is joining the worker thread(s) back up.

Something like that. I just need a few tips what concept to link up: i.e.
mutex? shared_mutex? lock? shared_lock?

I'll have a start_work, stop_work, and working type motif going on. I call
start_work to start the working thread going. Simple enough. I will call
stop_work to signal the worker thread(s) to stop and join up with the
worker threads.

Somewhere in between the worker thread is polling the lock does it need to
stop, do it's work, then back around again. And so on...

Thank you...

Regards,

Michael Powell



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