Boost logo

Boost :

From: James Talbut (James.Talbut_at_[hidden])
Date: 2008-05-09 05:01:26

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

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).

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.

See here for a sample:



> -----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.

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