can clone a thread?
Ali Çehreli
acehreli at yahoo.com
Tue Dec 10 09:14:47 PST 2013
On 12/10/2013 06:56 AM, Gianni Pisetta wrote:
> On Tuesday, 10 December 2013 at 13:39:17 UTC, Ali Çehreli wrote:
>> On 12/10/2013 04:04 AM, Gianni Pisetta wrote:
>>> Hi,
>>> i want to duplicate/clone a thread with the stack and tls, like the
>>> standard function fork() in c. Is in the phobos library a method that do
>>> the same thing?
>>>
>>> Gianni Pisetta
>>
>> Apparently, there isn't. However, you can use fork() directly from the
>> core.sys.posix.unistd module.
>>
>> Ali
>
> I had the same idea, but assumed (maybe wrongly) that it messes up the
> garbage collection because it creates a copy of the allocated objects in
> tls that the gc is not aware of. I searched the core.thread reference to
> see if it has a similar method but found none. Then i posted this
> question. So is it safe to use fork()? I now realized that i don't know
> how the gc works.
>
> Gianni Pisetta
I don't know such details but I presume fork() is safe. Grepping in
Phobos modules, process.d uses it.
Ali
More information about the Digitalmars-d-learn
mailing list