[webkit-reviews] review granted: [Bug 224179] BidiContext caching is not thread-safe : [Attachment 425144] Patch
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Mon Apr 5 16:56:30 PDT 2021
Darin Adler <darin at apple.com> has granted Chris Lord <clord at igalia.com>'s
request for review:
Bug 224179: BidiContext caching is not thread-safe
https://bugs.webkit.org/show_bug.cgi?id=224179
Attachment 425144: Patch
https://bugs.webkit.org/attachment.cgi?id=425144&action=review
--- Comment #2 from Darin Adler <darin at apple.com> ---
Comment on attachment 425144
--> https://bugs.webkit.org/attachment.cgi?id=425144
Patch
View in context: https://bugs.webkit.org/attachment.cgi?id=425144&action=review
> Source/WebCore/platform/text/BidiContext.cpp:65
> + static BidiContext* ltrContext;
> + static std::once_flag ltrContextOnceFlag;
> + std::call_once(ltrContextOnceFlag, [&]() {
> + ltrContext = &createUncached(0, U_LEFT_TO_RIGHT, false,
FromStyleOrDOM, 0).leakRef();
> + });
> + return *ltrContext;
I think the superior idiom is something more like this that does not use
leakRef:
static NeverDestroyed<RefPtr<BidiContext>> ltrContext;
static std::once_flag ltrContextOnceFlag;
std::call_once(ltrContextOnceFlag, [&]() {
ltrContext = createUncached(0, U_LEFT_TO_RIGHT, false, FromStyleOrDOM,
0);
});
return *ltrContext.get();
More information about the webkit-reviews
mailing list