From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-05-08 11:48:44
----- Original Message -----
From: "Anthony Williams" <anthony_w.geo_at_[hidden]>
Sent: Thursday, May 08, 2008 4:47 PM
Subject: Re: [boost] [thread] cache of initialized threads
> "vicente.botet" <vicente.botet_at_[hidden]> writes:
>> When we have to create lot of threads dynamicaly it will be better to
>> have a
>> 'pool' of initialized threads (the initialization of a thread takes
>> significant time). Please not that this has nothing to be with the
>> thread_pool class.
> If this isn't for worker threads in a thread pool, what is the purpose?
Well, both classes respond similar goals. The differences are much more
related to when the function is called and the interface provided by the
result of the request.
Imagine I have in my code a lot of threads that are created/destroyed
dynamicaly. For performances purposes I decide to creates this threads using
a thread factory which caches some idle threads instead of destroying them.
Whay I want is to preserv as much as possible the interface, so the result
of the thread factory must conform as much as possible to the thread
interface. Note that may initial application had not the notion of thread
The thread_pool I have used so far calls the function asynchronously,
because the function will be stored on the queue of pending. With a thread
cache either the threre is a cached_thread in the pool and we use it to
launch the user function, either the chached_threader will crate a new one.
In addition a cached thread should behaves as much as possible as a thread.
A thread_pool is much more a multi_task scheduler than a thread factory.
Maybe a thread_pool with the needed policies can give the same result. Why
. Task type : provide the thread functionality
. Scheduling Policy : immediate (Synchronous)
. Size Policy creates a new one when no more available
Do you know a thread_pool library allowing to implement the required
Vicente Juan Botet Escriba
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk