Boost logo

Boost :

From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-05-09 05:36:26

----- Original Message -----
From: "James Talbut" <James.Talbut_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, May 09, 2008 11:01 AM
Subject: Re: [boost] [thread] cache of initialized threads

> The Windows Threadpool (from Vista onwards) has quite a lot of features
> and is very usable, unfortunately prior to Vista it was much more
> limited and couldn't do tracking of job completion well.
> Using the threadpool involves a lot of functions calls, mainly for
> initialising static data (you create a structure and pass it to the
> function to init).
> The starting point is here:
> (though you don't
> actually have to create a threadpool yourself because there is a
> default).
> When a job is submitted and the pool is busy it 'may' create a new
> thread, depending on a private algorithm.
> You use SetThreadpoolCallbackRunsLong to influence this.
> Bearing in mind that thread creation is expensive (potentially much more
> so than simply completing a callback) you don't want to use a naiive
> implementation that always creates new threads (unless you know your
> jobs are big, which a library can't know).

What the user will do if there is no more idle threads if the thread pool do
not create it implicitly? May be resize the pool?
Yes, this is not a bad idea, the user could request this creation explicitly
with one specific parameter.

cached_thread thread_factory::make(Callable& fct);
cached_thread thread_factory::make(Callable& fct, force_creation_t&);

> Obviously, being as they are Windows functions they aren't C++ specific
> - the job function has a fixed signature taking a PVOID, for example.
> If you need to support Windows and pthreads I wouldn't use the windows
> threadpool, coming up with a suitable abstraction won't be simple - I'd
> go for something built on top of boost::threads.

Yes, you are right when writing a library on top of the boost thread
library. The question should not have the same answer if it the thread
library will includes this thread factory. Do you think that it would be
interesting to use this native thread pool in this case?

Thanks for all


> See here for a sample:
> HTH.
> Jim
>> -----Original Message-----
>> From: boost-bounces_at_[hidden]
>> [mailto:boost-bounces_at_[hidden]] On Behalf Of vicente.botet
>> Sent: 09 May 2008 09:48
>> To: boost_at_[hidden]
>> Subject: Re: [boost] [thread] cache of initialized threads
>> ----- Original Message -----
>> From: "James Talbut" <James.Talbut_at_[hidden]>
>> To: <boost_at_[hidden]>
>> Sent: Friday, May 09, 2008 9:39 AM
>> Subject: Re: [boost] [thread] cache of initialized threads
>> >> 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.
>> >
>> > I suspect it's not going to help you much, but this is how
>> the native
>> > thread pool behaves on Windows.
>> >
>> Hi Jim,
>> I don't know Windows at all. This is a good new, we will need only to
>> implement it for posix threads.
>> Could you give me some pointers?
>> Thanks,
>> Vicente
>> _______________________________________________
>> Unsubscribe & other changes:
> ________________________________________________________________________
> This e-mail, and any attachment, is confidential. If you have received it
> in error, do not use or disclose the information in any way, notify me
> immediately, and please delete it from your system.
> ________________________________________________________________________
> _______________________________________________
> Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at