From: Kai Brüning (kai_at_[hidden])
Date: 2007-01-25 11:48:44
thanks a lot, this satisfies my curiosity - at least for now. ;-)
(actually, now that I know it it's kind of obvious...)
>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
>> 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.
>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
-- Kai Brüning RagTime GmbH Tel:  (2103) 9657-0 Neustraße 69 Fax:  (2103) 9657-96 D-40721 Hilden mailto:kai_at_[hidden] Deutschland http://www.RagTime.de/