Boost logo

Threads-Devel :

From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2007-02-01 17:18:38

On 2/1/07, David Abrahams <dave_at_[hidden]> wrote:
> Anthony Williams <anthony_at_[hidden]> writes:
> [snipped]
> >
> > As you say, it's a trade-off --- heap allocation vs mutex/cond var. I can't
> > think of a particular reason why your scheme wouldn't work, but I guess Bill
> > didn't want to require a heap allocation for some reason.
> It's almost a sure bet that something like the small string
> optimization could be used to eliminate heap copies in 99% of cases.

The problem here is that in win32 threading API we can only pass a
long as argument, so if we want to pass more the boost::thread
constructor must wait on a condition variable that will do the copying
from one stack to the other. The heap allocation would eliminate the
condition variable need and could be faster for that. Although only
profiling to be sure, since heap allocation also incur synchronization
So it is just a matter of deciding if heap allocation is faster or not
than thread creation + synchronization on boost::thread constructor.

> --
> Dave Abrahams
> Boost Consulting

Felipe Magno de Almeida

Threads-Devel list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at