what keeps a COM object alive?
finalpatch
fengli at gmail.com
Wed Jun 12 07:40:59 PDT 2013
Hi Sean,
Thanks for your reply. I have no problem with client side COM
programming in D. What I'm asking is if I write a COM object in D (in
this case the D code is a COM server), then it looks like I have to
store a reference to that COM object in some globally reachable place
(eg. add it to a global array, so that it won't be destroyed by the GC
while the C++/.NET client is still using it), and then manually remove
that reference when the object's ref count drops to zero for the GC to
collect it.
This feels even more cumbersome than in C++ because in C++ we can simply
delete this in the Release() method, there's no need to store a
reference in a global place.
Sean Cavanaugh <WorksOnMyMachine at gmail.com> writes:
> COM is by definition ref counted. In D you generally need to store a
> COM pointer in a struct and maintain the refcount with that struct
> (increment on copy, decrement in destructor, etc). Its not too hard,
> as 'alias this' usage can wrap the pointer's methods easily enough.
>
>
--
finalpatch
More information about the Digitalmars-d-learn
mailing list