On Tue, Jan 24 2023 at 02:53:42 PM -0600, Michael Catanzaro <mcatanz...@redhat.com> wrote:
E.g. for GObjects, we could write GWeakPtr, but this would not be very ergonomic, and it won't work for arbitrary types.

So Carlos Garcia added this in https://commits.webkit.org/259482@main.

There is a downside to GWeakPtr: global locking. Even though GWeakPtr is not threadsafe and each GObject keeps its own list of weak locations, all GObjects nonetheless share the same global lock for weak pointer locations. There is probably a relatively high cost compared to WTF::WeakPtr, so I'd say it should be used only when it provides valuable safety (e.g. in member variables) rather than spammed (e.g. in local variables).

Michael


_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev

Reply via email to