Boost logo

Boost :

From: Schalk_Cronje_at_[hidden]
Date: 2002-06-10 05:56:11

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

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

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

  thread(const functiono<void>& threadfunc, thread_attr* p=0);

Alternatively, one can have thread_attr be some form of portable interface
where the parts that is not implemented does nothing or returns false. there
are many ways of accomplishing this, the following is just an idea.

struct thread_attr
  struct stacksize
    enum {supported=true};
    bool set( size_t );
    size_t get() const;

  struct stackptr
    enum {supported=true};
    bool set(void*,size_t);
    std::pair<void*,size_t> get() const;

----------------------------------[ .signature ]---
Schalk W. Cronjé,

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