Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
January 30, 2016 Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop? | ||||
---|---|---|---|---|
| ||||
Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop? My lib.so is writed in D, and I use the GC.and then I am used the dll in my program that is writed in C++. I want to know when the GC(in lib.so's runtime) start runing, will my program be stoped,until the GC stop? sorry , my english is bad. I will use chinese to describe this question: 我用D语言写了一个的动态库,其中里面的内存分配和回收用的是GC。现在我的C++程序去调用这个动态库。我想知道,当动态库所依赖的的D的运行时中GC运行的时候,是不是我的整个程序都会暂停住,知道GC回收完毕再次唤醒? |
January 30, 2016 Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dsby | On Sat, 30 Jan 2016 14:41:18 +0000, Dsby wrote:
> Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop?
The GC will stop every thread it knows about. If you have a C++ thread that you want to run while the GC is running, you can get that by not telling the D runtime about it. This will limit your ability to interact with D from that thread somewhat -- and it will interfere more with your ability to *safely* interact with D even more.
If you never allocate GC memory, of course, the GC will never run.
|
January 31, 2016 Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Wright | On Saturday, 30 January 2016 at 16:06:37 UTC, Chris Wright wrote:
> On Sat, 30 Jan 2016 14:41:18 +0000, Dsby wrote:
>
>> Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop?
>
> The GC will stop every thread it knows about. If you have a C++ thread that you want to run while the GC is running, you can get that by not telling the D runtime about it. This will limit your ability to interact with D from that thread somewhat -- and it will interfere more with your ability to *safely* interact with D even more.
>
> If you never allocate GC memory, of course, the GC will never run.
Thanks, if I use the D dylib,I should run " rt_init(); " in every thread which i used the D dylib?
|
January 31, 2016 Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dsby | On Sunday, 31 January 2016 at 03:45:01 UTC, Dsby wrote: > > Thanks, if I use the D dylib,I should run " rt_init(); " in every thread which i used the D dylib? No. rt_init only needs to be called once for the process. You need to call core.thread.attach_this [1] so that runtime is aware of your external thread. Note that this does not apply to the thread that calls rt_init. [1] http://dlang.org/phobos/core_thread.html#.thread_attachThis |
January 31, 2016 Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Sunday, 31 January 2016 at 05:28:02 UTC, Mike Parker wrote:
> need to call core.thread.attach_this [1] so that runtime is
Sorry, that's core.thread.thread_attachThis
|
January 31, 2016 Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Sunday, 31 January 2016 at 05:29:06 UTC, Mike Parker wrote:
> On Sunday, 31 January 2016 at 05:28:02 UTC, Mike Parker wrote:
>
>> need to call core.thread.attach_this [1] so that runtime is
>
> Sorry, that's core.thread.thread_attachThis
ok。thanks.
|
Copyright © 1999-2021 by the D Language Foundation