Boost logo

Threads-Devel :

From: David Abrahams (dave_at_[hidden])
Date: 2007-02-03 16:20:04


"Felipe Magno de Almeida" <felipe.m.almeida_at_[hidden]> writes:

> 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

Yes, but if you use the SSO you can (usually) do stack allocation and
(on 32-bit platforms) pass the address across the thread boundary in
that long. Am I missing something?

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Threads-Devel list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk