Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop?

2016-01-30 Thread Chris Wright via Digitalmars-d-learn
On Sat, 30 Jan 2016 14:41:18 +, 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.


Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop?

2016-01-30 Thread Dsby via Digitalmars-d-learn
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回收完毕再次唤醒?


Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop?

2016-01-30 Thread Mike Parker via Digitalmars-d-learn

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


Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop?

2016-01-30 Thread Mike Parker via Digitalmars-d-learn

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


Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop?

2016-01-30 Thread Dsby via Digitalmars-d-learn

On Saturday, 30 January 2016 at 16:06:37 UTC, Chris Wright wrote:

On Sat, 30 Jan 2016 14:41:18 +, 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?


Re: Use the D dylib in my C++ program,when the D's GC(in the dylib runtime) run. will not my program stop?

2016-01-30 Thread Dsby via Digitalmars-d-learn

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.