[webkit-changes] [WebKit/WebKit] 034516: NativePromise should provide a safe way to pass so...

Jean-Yves Avenard noreply at github.com
Wed Oct 4 16:21:14 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0345168e97b5e2c1fa074c8b5c9d721e23ae60ce
      https://github.com/WebKit/WebKit/commit/0345168e97b5e2c1fa074c8b5c9d721e23ae60ce
  Author: Jean-Yves Avenard <jya at apple.com>
  Date:   2023-10-04 (Wed, 04 Oct 2023)

  Changed paths:
    M Source/WTF/wtf/CrossThreadCopier.cpp
    M Source/WTF/wtf/CrossThreadCopier.h
    M Source/WTF/wtf/Forward.h
    M Source/WTF/wtf/NativePromise.h
    M Source/WTF/wtf/TypeTraits.h
    M Source/WebCore/Modules/webaudio/AsyncAudioDecoder.cpp
    M Source/WebCore/Modules/webaudio/AsyncAudioDecoder.h
    M Source/WebCore/Modules/webaudio/BaseAudioContext.cpp
    M Source/WebCore/dom/ExceptionOr.h
    M Source/WebKit/Scripts/webkit/messages.py
    M Source/WebKit/Scripts/webkit/tests/TestWithCVPixelBufferMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithImageDataMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithLegacyReceiverMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithSemaphoreMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithStreamMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithSuperclassMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithoutAttributesMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithoutUsingIPCConnectionMessages.h
    M Tools/TestWebKitAPI/Tests/IPC/IPCTestUtilities.h
    M Tools/TestWebKitAPI/Tests/WTF/NativePromise.cpp

  Log Message:
  -----------
  NativePromise should provide a safe way to pass some argument types
https://bugs.webkit.org/show_bug.cgi?id=262437
rdar://116274506

Reviewed by Youenn Fablet.

We expand the scope of CrossThreadCopier so that it can always deal with
r-values, including those without an isolatedCopy() method.
Add specialisation for void, std::tuple and AtomString.
We allow using non-threadsafe refcount when using only r-value as the object
can be safely moved around.

NativePromise aims to add a layer between the producer and the consumer such
that the producer doesn't have to know the threading model of the consumer.
To achieve this, we needed to have a way to guarantee that the object returned
by the producer is usable on any threads. By using this expanded CrossThreadCopier
in NativePromise we achieve that goal.
It is now safe to have NativePromise using Strings, AtomString and any
supported composite objects using those (tuple, variant, pair, expected,
Vector, optional, HashMap, HashSet)
Should more specialisation be needed, they should be added to CrossThreadCopier.

Non Exclusive NativePromise requires the programmer to explicitly define
the behaviour: that is always use CrossThreadCopy or never do.

Add API tests.

* Source/WTF/wtf/CrossThreadCopier.cpp:
* Source/WTF/wtf/CrossThreadCopier.h:
* Source/WTF/wtf/Forward.h:
* Source/WTF/wtf/NativePromise.h:
(WTF::operator|):
(WTF::operator&):
* Source/WTF/wtf/TypeTraits.h:
* Source/WebCore/Modules/webaudio/AsyncAudioDecoder.cpp: Make use of the ability of
rejecting with an Exception object.
(WebCore::AsyncAudioDecoder::decodeAsync):
* Source/WebCore/Modules/webaudio/AsyncAudioDecoder.h: Update definition of DecodingTaskPromise
* Source/WebCore/Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::decodeAudioData):
* Source/WebCore/dom/ExceptionOr.h:
* Source/WebKit/Scripts/webkit/messages.py:
(message_to_struct_declaration):
* Source/WebKit/Scripts/webkit/tests/TestWithCVPixelBufferMessages.h:
* Source/WebKit/Scripts/webkit/tests/TestWithImageDataMessages.h:
* Source/WebKit/Scripts/webkit/tests/TestWithLegacyReceiverMessages.h:
* Source/WebKit/Scripts/webkit/tests/TestWithSemaphoreMessages.h:
* Source/WebKit/Scripts/webkit/tests/TestWithStreamMessages.h:
* Source/WebKit/Scripts/webkit/tests/TestWithSuperclassMessages.h:
* Source/WebKit/Scripts/webkit/tests/TestWithoutAttributesMessages.h:
* Source/WebKit/Scripts/webkit/tests/TestWithoutUsingIPCConnectionMessages.h:
* Tools/TestWebKitAPI/Tests/WTF/NativePromise.cpp:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/268880@main




More information about the webkit-changes mailing list