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:
http://msdn.microsoft.com/en-us/library/ms682456.aspx (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).

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:
http://msdn.microsoft.com/en-us/library/ms686980(VS.85).aspx

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:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>

________________________________________________________________________
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 acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk