Boost logo

Threads-Devel :

From: Kai Brüning (kai_at_[hidden])
Date: 2007-01-25 11:48:44


Hi Anthony,

thanks a lot, this satisfies my curiosity - at least for now. ;-)

(actually, now that I know it it's kind of obvious...)

Kai

>Roland Schwarz <roland.schwarz_at_[hidden]> writes:
>
>> Kai Brüning wrote:
>>
>>> Why does thread::thread wait till the thread
>>> is started (at least in 1.33.1)?
>>
>> I am not sure I understand your question. Can you please try to be more
>> specific?
>>
>> There is no explicit mechanism to wait, basically this property is
>> inherited from the respective low level API.
>
>thread::thread(func) constructs a new thread_param object, and creates a
>thread, set to run at thread_proxy, passing in the address of the thread_param
>object. It then calls param.wait() to ensure that the thread has started.
>
>This is to ensure that the function object has been correctly copied into the
>context of the new thread before the thread constructor returns --- this is
>done by thread_proxy, which copies the function object, notifies the
>thread_param, and then calls the function.
>
>If this did not happen, then it becomes much harder to use function objects
>with threads, as you need to ensure that the object referenced by the
>newly-created thread has not already been destroyed, which essentially
>requires it to be heap allocated.
>
>Anthony
>--
>Anthony Williams
>Just Software Solutions Ltd - http://www.justsoftwaresolutions.co.uk
>Registered in England, Company Number 5478976.
>Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL
>_______________________________________________
>threads-devel mailing list
>threads-devel_at_[hidden]
>http://lists.boost.org/mailman/listinfo.cgi/threads-devel

-- 
Kai Brüning
RagTime GmbH                          Tel: [49] (2103) 9657-0
Neustraße 69                          Fax: [49] (2103) 9657-96
D-40721 Hilden                        mailto:kai_at_[hidden]
Deutschland                           http://www.RagTime.de/

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