Re: Boost::thread cancellation
- From: Marcel Müller <news.5.maazl@xxxxxxxxxxxxxxx>
- Date: Mon, 07 Apr 2008 16:18:56 +0200
Venkatraman.S. wrote:
I totally concur, but let me state my problem more clearly :
i have 'a' boss and 'a' worker - the boss receives requests on a
socket and dispatches to the worker thread. If the worker takes more
than 'n' milli seconds then that worker thread needs to be killed. The
way i have presently implemented this is : the boss spawns a new
thread as each request drops in - but as you know, this is again a bad
design. Hence am just thinking about any other possible design ..any
thoughts??
As I said sooner: a queue. Post the requests to a queue and start a couple of workers that proceed the requests.
Either the worker code has to deal with the time-outs itself, or a manager thread has to check for too old workers from time to time. The first case is the most clean solution. The second way requires the workers to check their termination signal from time to time. But the manager removes the timed-out thread immediately from the worker pool and replaces it with a new one to keep the queue responsive.
Marcel
.
- References:
- Boost::thread cancellation
- From: Venkatraman.S.
- Re: Boost::thread cancellation
- From: Marcel Müller
- Re: Boost::thread cancellation
- From: Venkatraman.S.
- Boost::thread cancellation
- Prev by Date: Re: Boost::thread cancellation
- Next by Date: Re: reg SIGSERV in pThreads
- Previous by thread: Re: Boost::thread cancellation
- Next by thread: Re: Boost::thread cancellation
- Index(es):
Relevant Pages
|