[Tickit-dev] Refcounting objects
Paul "LeoNerd" Evans
leonerd at leonerd.org.uk
Sat Oct 8 12:15:06 BST 2016
A while ago I added refcounting to pen objects, to simplify the way
that HLLs wrap these objects, and to allow more efficient multiple
reference of the same pen rather than creating immutable clones.
I've just recently added the same sort of refcounting logic and methods
to the other object types - terminals, renderbuffers and windows.
I've already removed the `tickit_pen_destroy` function in favour of
using `unref`; I'll be doing similar with the other types in a short
while. So if you have any C code using `tickit_CLASS_destroy`, just
change it for `tickit_CLASS_unref` instead.
At some point I might add some macros for safer coding:
#define TICKIT_PEN_UNREF(p) do { tickit_pen_unref(p); p = NULL } while(0)
etc...
One detail I haven't quite finished thinking through is how refcounting
ought to work between parent and child windows. I will probably copy
the same semantics as the native perl implementation uses; namely, that
parent windows strongly hold on to their children but to avoid a cycle,
only weakly onto their parent. This means you can destroy an entire
tree of windows by just unref'ing the root of that tree.
Does anyone have any particular concerns of this model? If not, I guess
I'll go for that...
--
Paul "LeoNerd" Evans
leonerd at leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://mail.leonerd.org.uk/pipermail/tickit-dev/attachments/20161008/7eba1606/attachment.sig>
More information about the Tickit-dev
mailing list