[Webkit-unassigned] [Bug 238871] Multiple uses of ThreadSafeRefCounted and CanMakeWeakPtr with non-thread-safe WeakPtr

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Apr 6 09:44:31 PDT 2022


https://bugs.webkit.org/show_bug.cgi?id=238871

--- Comment #4 from Kimmo Kinnunen <kkinnunen at apple.com> ---
(In reply to Chris Dumez from comment #2)
> Not that in general, it is perfectly OK for a class to subclass
> ThreadSafeRefCounted and CanMakeWeakPtr and it is not indicative of a bug.
> It really depends on how you're using WeakPtr.
> 
> E.g., the following case is pretty common in WebKit:
> 1. We have an object A that gets constructed and destroyed on the main
> thread.
> 2. We sometimes pass object A to a background thread T and then back to the
> main thread.
> 
> It is OK as long as you only check the WeakPtr on the main thread and make
> sure that the object is always destroyed on the main thread.

No, incorrect.
If you can guarantee that first ref is taken in main thread and last ref is dropped in main thread, then it should not be ThreadSafeRefCounted.

There's no case ThreadSafeRefCounted and CanMakeWeakPtr are correct.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20220406/9d3a5aef/attachment.htm>


More information about the webkit-unassigned mailing list