Reference counting questions

Johannes Pfau spam at example.com
Sat Jul 23 03:35:42 PDT 2011


Jesse Phillips wrote:
>I don't really think stdio is the place to see modern D ref counting.
>The container class has an Array which is built to use RefCounted. I
>had tried my and at explaining how to use it: http://stackoverflow.com/
>questions/4632355/making-a-reference-counted-object-in-d-using-
>refcountedt/4635050#4635050
>
>I'm not really sure if all the details have been worked out. Hopefully
>I explained it correctly and that it gives you an idea of how to make
>ref counting work.

Totally overlooked a 'small' problem with RefCounted: It can't work for
cairoD ;-) In cairo the c handle is already reference-counted, so I
should use cairo_*_[de]reference(ptr) instead of my own counter, but
that can't be done with RefCounted. I think I'll have to adapt the
RefCounted implementation for cairoD.

But I can still use RefCounted in other projects.

BTW: RefCounted also uses std.algorithm.swap in it's opAssign. Still
wondering what that's supposed to do.
-- 
Johannes Pfau



More information about the Digitalmars-d-learn mailing list