Boost logo

Boost :

From: William E. Kempf (williamkempf_at_[hidden])
Date: 2002-06-10 08:35:39


----- Original Message -----
From: <Schalk_Cronje_at_[hidden]>

> One thing that might be useful for the next version of Boost.threads is
> setting additional attributes when creating a new thread.

Planned.

> One example is to set the stack size in order to reduce the memory
footprint
> of processes spawning many threads. Originally I thought that this might
be
> passed as an optional parameter to the c-tor, unfortunately it seems that
> the stack size is not portable. [Under pthreads it's a case of setting the
> attributes via pthreads_attr_setstacksize before calling pthread_create,
but
> this limits the maximum stack size. Under winthreads it seems that one can
> only set the initial stack size, bit there is no explicit top limit].

It's actually more complicated then that. You can't necessarily set a stack
size under pthreads. On some platforms you can instead set a pointer to a
"stack" you've allocated yourself. Theoretically, at least, there may also
be some platforms in which neither thread attribute is available.

> What might be a good idea is to pass an optional third parameter into the
> c-tor which is a wrapper for an implementation-specific set of attributes.
>
> typedef IMPLEMENTATION thread_attr;
>
> class thread
> {
> public:
>
> thread(const functiono<void>& threadfunc, thread_attr* p=0);
> };

This is basically what's planned. This will also be the solution used for
mutex attributes as well.

Bill Kempf


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk