Title: [284135] trunk
Revision
284135
Author
[email protected]
Date
2021-10-13 17:09:18 -0700 (Wed, 13 Oct 2021)

Log Message

Clearly distinguish serial from concurrent WorkQueue
https://bugs.webkit.org/show_bug.cgi?id=231418
rdar://problem/84021977

Reviewed by Chris Dumez.

Source/_javascript_Core:

Replace instances of WorkQueue being constructed as a concurrent one
with ConcurrentWorkQueue.
Remove the now unnecessary use of WorkQueue::Type::Serial in constructor.

* jit/ExecutableAllocator.cpp:
(JSC::dumpJITMemory):
* runtime/Watchdog.cpp:
(JSC::Watchdog::Watchdog):

Source/WebCore:

Replace instances of WorkQueue being constructed as a concurrent one
with ConcurrentWorkQueue.
Remove the now unnecessary use of WorkQueue::Type::Serial in constructor.

Fly-by fix: make use of NeverDestroyed in some methods.

No change in observable behaviour.

* platform/graphics/ImageSource.cpp:
(WebCore::ImageSource::decodingQueue):
* platform/graphics/filters/FEConvolveMatrix.cpp:
(WebCore::FEConvolveMatrix::platformApplySoftware):
* platform/mediastream/libwebrtc/LibWebRTCAudioModule.cpp:
(WebCore::LibWebRTCAudioModule::LibWebRTCAudioModule):
* platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
(WebCore::MockRealtimeVideoSourceMac::MockRealtimeVideoSourceMac):
* platform/network/BlobRegistryImpl.cpp:
(WebCore::blobUtilityQueue):
* platform/network/DataURLDecoder.cpp:
(WebCore::DataURLDecoder::decodeQueue):
* storage/StorageQuotaManager.cpp:
(WebCore::StorageQuotaManager::StorageQuotaManager):
* workers/service/server/RegistrationDatabase.cpp:
(WebCore::registrationDatabaseWorkQueue):

Source/WebKit:

Replace instances of WorkQueue being constructed as a concurrent one
with ConcurrentWorkQueue.
Remove the now unnecessary use of WorkQueue::Type::Serial in constructor.

* GPUProcess/GPUProcess.cpp:
(WebKit::GPUProcess::videoMediaStreamTrackRendererQueue):
(WebKit::GPUProcess::libWebRTCCodecsQueue):
* NetworkProcess/cache/CacheStorageEngine.cpp:
(WebKit::CacheStorage::Engine::Engine):
* NetworkProcess/cache/NetworkCacheIOChannel.h:
* NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm:
(WebKit::NetworkCache::IOChannel::read):
(WebKit::NetworkCache::IOChannel::write):
* NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp:
(WebKit::NetworkCache::IOChannel::read):
(WebKit::NetworkCache::IOChannel::write):
* NetworkProcess/cache/NetworkCacheIOChannelGLib.cpp:
(WebKit::NetworkCache::IOChannel::read):
(WebKit::NetworkCache::IOChannel::readSyncInThread):
(WebKit::NetworkCache::IOChannel::write):
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::Storage):
* NetworkProcess/cache/NetworkCacheStorage.h:
(WebKit::NetworkCache::Storage::ioQueue):
(WebKit::NetworkCache::Storage::backgroundIOQueue):
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::Connection::open):
* Shared/mac/MediaFormatReader/MediaFormatReader.cpp:
(WebKit::readerQueue):
* Shared/mac/MediaFormatReader/MediaTrackReader.cpp:
(WebKit::MediaTrackReader::storageQueue):
* UIProcess/API/APIContentRuleListStore.cpp:
(API::ContentRuleListStore::ContentRuleListStore):
* UIProcess/API/APIContentRuleListStore.h:
* UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
(WebKit::appBoundDomainQueue):
* WebProcess/GPU/media/RemoteAudioSourceProviderManager.cpp:
(WebKit::RemoteAudioSourceProviderManager::RemoteAudioSourceProviderManager):
* WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp:
(WebKit::LibWebRTCCodecs::LibWebRTCCodecs):
* WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::EventDispatcher):
* WebProcess/cocoa/RemoteCaptureSampleManager.cpp:
(WebKit::RemoteCaptureSampleManager::RemoteCaptureSampleManager):

Source/WTF:

We split the WorkQueue code so that it becomes either a serial or concurrent one.
A concurrent WorkQueue doesn't guarantee the order in which the queued tasks will run.
That makes for a footgun if a consumer took a WorkQueue and was expecting
it to be a serial one.

WorkQueue (serial) and ConcurrentWorkQueue are made to both inherit from WorkQueueBase.
A class should inherit from either the WorkQueue or the ConcurrentWorkQueue class.

The Storage class present in NetworkCacheStore is the only code that was
using a WorkQueue that could be either. For this class we will pass a
WorkQueueBase; use of the base class directly is discouraged.

No change in observable behaviour.

* wtf/SuspendableWorkQueue.cpp:
(WTF::SuspendableWorkQueue::SuspendableWorkQueue):
* wtf/WorkQueue.cpp:
(WTF::WorkQueueBase::create): removed
(WTF::WorkQueueBase::WorkQueueBase):
(WTF::WorkQueueBase::~WorkQueueBase):
(WTF::WorkQueue::create):
(WTF::ConcurrentWorkQueue::create):
(WTF::WorkQueueBase::dispatchSync):
(WTF::ConcurrentWorkQueue:apply):
* wtf/WorkQueue.h:
(WTF::WorkQueueBase::dispatchQueue const):
(WTF::executeFunction): remove unused method declaration.
(WTF::WorkQueue::runLoop const):
(WTF::WorkQueue::WorkQueue):
(WTF::ConcurrentWorkQueue::ConcurrentWorkQueue):
* wtf/cocoa/WorkQueueCocoa.cpp:
(WTF::WorkQueueBase::dispatch):
(WTF::WorkQueueBase::dispatchAfter):
(WTF::WorkQueueBase::dispatchSync):
(WTF::WorkQueueBase::WorkQueueBase):
(WTF::WorkQueueBase::platformInitialize):
(WTF::WorkQueueBase::platformInvalidate):
(WTF::WorkQueue::WorkQueue):
(WTF::WorkQueue::constructMainWorkQueue):
(WTF::ConcurrentWorkQueue::apply):
* wtf/generic/WorkQueueGeneric.cpp:
(WorkQueue::WorkQueue):
(WorkQueueBase::WorkQueueBase):
(WorkQueueBase::platformInitialize):
(WorkQueueBase::platformInvalidate):
(WorkQueueBase::dispatch):
(WorkQueueBase::dispatchAfter):

Tools:

* TestWebKitAPI/Tests/WTF/WorkQueue.cpp:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (284134 => 284135)


--- trunk/Source/_javascript_Core/ChangeLog	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-10-14 00:09:18 UTC (rev 284135)
@@ -1,3 +1,20 @@
+2021-10-13  Jean-Yves Avenard  <[email protected]>
+
+        Clearly distinguish serial from concurrent WorkQueue
+        https://bugs.webkit.org/show_bug.cgi?id=231418
+        rdar://problem/84021977
+
+        Reviewed by Chris Dumez.
+
+        Replace instances of WorkQueue being constructed as a concurrent one
+        with ConcurrentWorkQueue.
+        Remove the now unnecessary use of WorkQueue::Type::Serial in constructor.
+
+        * jit/ExecutableAllocator.cpp:
+        (JSC::dumpJITMemory):
+        * runtime/Watchdog.cpp:
+        (JSC::Watchdog::Watchdog):
+
 2021-10-13  Yusuke Suzuki  <[email protected]>
 
         [JSC] Update adjusted thread numbers

Modified: trunk/Source/_javascript_Core/jit/ExecutableAllocator.cpp (284134 => 284135)


--- trunk/Source/_javascript_Core/jit/ExecutableAllocator.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/_javascript_Core/jit/ExecutableAllocator.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -1188,7 +1188,7 @@
     static std::once_flag once;
     std::call_once(once, [] {
         buffer = bitwise_cast<uint8_t*>(malloc(bufferSize));
-        flushQueue.construct(WorkQueue::create("jsc.dumpJITMemory.queue", WorkQueue::Type::Serial, WorkQueue::QOS::Background));
+        flushQueue.construct(WorkQueue::create("jsc.dumpJITMemory.queue", WorkQueue::QOS::Background));
         std::atexit([] {
             Locker locker { dumpJITMemoryLock };
             DumpJIT::flush();

Modified: trunk/Source/_javascript_Core/runtime/Watchdog.cpp (284134 => 284135)


--- trunk/Source/_javascript_Core/runtime/Watchdog.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/_javascript_Core/runtime/Watchdog.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -39,7 +39,7 @@
     , m_callback(nullptr)
     , m_callbackData1(nullptr)
     , m_callbackData2(nullptr)
-    , m_timerQueue(WorkQueue::create("jsc.watchdog.queue", WorkQueue::Type::Serial, WorkQueue::QOS::Utility))
+    , m_timerQueue(WorkQueue::create("jsc.watchdog.queue", WorkQueue::QOS::Utility))
 {
 }
 

Modified: trunk/Source/WTF/ChangeLog (284134 => 284135)


--- trunk/Source/WTF/ChangeLog	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WTF/ChangeLog	2021-10-14 00:09:18 UTC (rev 284135)
@@ -1,3 +1,59 @@
+2021-10-13  Jean-Yves Avenard  <[email protected]>
+
+        Clearly distinguish serial from concurrent WorkQueue
+        https://bugs.webkit.org/show_bug.cgi?id=231418
+        rdar://problem/84021977
+
+        Reviewed by Chris Dumez.
+
+        We split the WorkQueue code so that it becomes either a serial or concurrent one.
+        A concurrent WorkQueue doesn't guarantee the order in which the queued tasks will run.
+        That makes for a footgun if a consumer took a WorkQueue and was expecting
+        it to be a serial one.
+
+        WorkQueue (serial) and ConcurrentWorkQueue are made to both inherit from WorkQueueBase.
+        A class should inherit from either the WorkQueue or the ConcurrentWorkQueue class.
+
+        The Storage class present in NetworkCacheStore is the only code that was
+        using a WorkQueue that could be either. For this class we will pass a
+        WorkQueueBase; use of the base class directly is discouraged.
+
+        No change in observable behaviour.
+
+        * wtf/SuspendableWorkQueue.cpp:
+        (WTF::SuspendableWorkQueue::SuspendableWorkQueue):
+        * wtf/WorkQueue.cpp:
+        (WTF::WorkQueueBase::create): removed
+        (WTF::WorkQueueBase::WorkQueueBase):
+        (WTF::WorkQueueBase::~WorkQueueBase):
+        (WTF::WorkQueue::create):
+        (WTF::ConcurrentWorkQueue::create):
+        (WTF::WorkQueueBase::dispatchSync):
+        (WTF::ConcurrentWorkQueue:apply):
+        * wtf/WorkQueue.h:
+        (WTF::WorkQueueBase::dispatchQueue const):
+        (WTF::executeFunction): remove unused method declaration.
+        (WTF::WorkQueue::runLoop const):
+        (WTF::WorkQueue::WorkQueue):
+        (WTF::ConcurrentWorkQueue::ConcurrentWorkQueue):
+        * wtf/cocoa/WorkQueueCocoa.cpp:
+        (WTF::WorkQueueBase::dispatch):
+        (WTF::WorkQueueBase::dispatchAfter):
+        (WTF::WorkQueueBase::dispatchSync):
+        (WTF::WorkQueueBase::WorkQueueBase):
+        (WTF::WorkQueueBase::platformInitialize):
+        (WTF::WorkQueueBase::platformInvalidate):
+        (WTF::WorkQueue::WorkQueue):
+        (WTF::WorkQueue::constructMainWorkQueue):
+        (WTF::ConcurrentWorkQueue::apply):
+        * wtf/generic/WorkQueueGeneric.cpp:
+        (WorkQueue::WorkQueue):
+        (WorkQueueBase::WorkQueueBase):
+        (WorkQueueBase::platformInitialize):
+        (WorkQueueBase::platformInvalidate):
+        (WorkQueueBase::dispatch):
+        (WorkQueueBase::dispatchAfter):
+
 2021-10-13  Sihui Liu  <[email protected]>
 
         Enable FileSystemAccess and AccessHandle by default

Modified: trunk/Source/WTF/wtf/SuspendableWorkQueue.cpp (284134 => 284135)


--- trunk/Source/WTF/wtf/SuspendableWorkQueue.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WTF/wtf/SuspendableWorkQueue.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -34,7 +34,7 @@
 }
 
 SuspendableWorkQueue::SuspendableWorkQueue(const char* name, QOS qos)
-    : WorkQueue(name, Type::Serial, qos)
+    : WorkQueue(name, qos)
 {
     ASSERT(isMainThread());
 }

Modified: trunk/Source/WTF/wtf/WorkQueue.cpp (284134 => 284135)


--- trunk/Source/WTF/wtf/WorkQueue.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WTF/wtf/WorkQueue.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -50,23 +50,28 @@
     return *mainWorkQueue.get();
 }
 
-Ref<WorkQueue> WorkQueue::create(const char* name, Type type, QOS qos)
+WorkQueueBase::WorkQueueBase(const char* name, Type type, QOS qos)
 {
-    return adoptRef(*new WorkQueue(name, type, qos));
+    platformInitialize(name, type, qos);
 }
 
-WorkQueue::WorkQueue(const char* name, Type type, QOS qos)
+WorkQueueBase::~WorkQueueBase()
 {
-    platformInitialize(name, type, qos);
+    platformInvalidate();
 }
 
-WorkQueue::~WorkQueue()
+Ref<WorkQueue> WorkQueue::create(const char* name, QOS qos)
 {
-    platformInvalidate();
+    return adoptRef(*new WorkQueue(name, qos));
 }
 
+Ref<ConcurrentWorkQueue> ConcurrentWorkQueue::create(const char* name, QOS qos)
+{
+    return adoptRef(*new ConcurrentWorkQueue(name, qos));
+}
+
 #if !PLATFORM(COCOA)
-void WorkQueue::dispatchSync(Function<void()>&& function)
+void WorkQueueBase::dispatchSync(Function<void()>&& function)
 {
     BinarySemaphore semaphore;
     dispatch([&semaphore, function = WTFMove(function)]() mutable {
@@ -76,7 +81,7 @@
     semaphore.wait();
 }
 
-void WorkQueue::concurrentApply(size_t iterations, WTF::Function<void (size_t index)>&& function)
+void ConcurrentWorkQueue::apply(size_t iterations, WTF::Function<void(size_t index)>&& function)
 {
     if (!iterations)
         return;

Modified: trunk/Source/WTF/wtf/WorkQueue.h (284134 => 284135)


--- trunk/Source/WTF/wtf/WorkQueue.h	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WTF/wtf/WorkQueue.h	2021-10-14 00:09:18 UTC (rev 284135)
@@ -41,41 +41,30 @@
 
 namespace WTF {
 
-class WorkQueue : public FunctionDispatcher {
-
+class WorkQueueBase : public FunctionDispatcher {
 public:
-    enum class Type {
-        Serial,
-        Concurrent
-    };
     using QOS = Thread::QOS;
 
-    WTF_EXPORT_PRIVATE static WorkQueue& main();
+    ~WorkQueueBase() override;
 
-    WTF_EXPORT_PRIVATE static Ref<WorkQueue> create(const char* name, Type = Type::Serial, QOS = QOS::Default);
-    ~WorkQueue() override;
-
     WTF_EXPORT_PRIVATE void dispatch(Function<void()>&&) override;
     WTF_EXPORT_PRIVATE virtual void dispatchAfter(Seconds, Function<void()>&&);
     WTF_EXPORT_PRIVATE virtual void dispatchSync(Function<void()>&&);
 
-    WTF_EXPORT_PRIVATE static void concurrentApply(size_t iterations, WTF::Function<void(size_t index)>&&);
-
 #if USE(COCOA_EVENT_LOOP)
     dispatch_queue_t dispatchQueue() const { return m_dispatchQueue.get(); }
-#else
-    RunLoop& runLoop() const { return *m_runLoop; }
 #endif
 
 protected:
-    WorkQueue(const char* name, Type, QOS);
-
-private:
-    static Ref<WorkQueue> constructMainWorkQueue();
+    enum class Type : bool {
+        Serial,
+        Concurrent
+    };
+    WorkQueueBase(const char* name, Type, QOS);
 #if USE(COCOA_EVENT_LOOP)
-    explicit WorkQueue(OSObjectPtr<dispatch_queue_t>&&);
+    explicit WorkQueueBase(OSObjectPtr<dispatch_queue_t>&&);
 #else
-    explicit WorkQueue(RunLoop&);
+    explicit WorkQueueBase(RunLoop&);
 #endif
 
     void platformInitialize(const char* name, Type, QOS);
@@ -82,7 +71,6 @@
     void platformInvalidate();
 
 #if USE(COCOA_EVENT_LOOP)
-    static void executeFunction(void*);
     OSObjectPtr<dispatch_queue_t> m_dispatchQueue;
 #else
     RunLoop* m_runLoop;
@@ -89,6 +77,52 @@
 #endif
 };
 
+/**
+ * A WorkQueue is a function dispatching interface like FunctionDispatcher.
+ * Runnables dispatched to a WorkQueue are required to execute serially.
+ * That is, two different runnables dispatched to the WorkQueue should never be allowed to execute simultaneously.
+ * They may be executed on different threads but can safely be used by objects that aren't already threadsafe.
+ */
+class WorkQueue : public WorkQueueBase {
+public:
+    WTF_EXPORT_PRIVATE static WorkQueue& main();
+
+    WTF_EXPORT_PRIVATE static Ref<WorkQueue> create(const char* name, QOS = QOS::Default);
+
+#if !USE(COCOA_EVENT_LOOP)
+    RunLoop& runLoop() const { return *m_runLoop; }
+#endif
+
+protected:
+    WorkQueue(const char* name, QOS qos)
+        : WorkQueueBase(name, Type::Serial, qos)
+    {
+    }
+private:
+#if USE(COCOA_EVENT_LOOP)
+    explicit WorkQueue(OSObjectPtr<dispatch_queue_t>&&);
+#else
+    explicit WorkQueue(RunLoop&);
+#endif
+    static Ref<WorkQueue> constructMainWorkQueue();
+};
+
+/**
+ * A ConcurrentWorkQueue unlike a WorkQueue doesn't guarantee the order in which the dispatched runnable will run
+ * and each can run concurrently on different threads.
+ */
+class ConcurrentWorkQueue final : public WorkQueueBase {
+public:
+    WTF_EXPORT_PRIVATE static Ref<ConcurrentWorkQueue> create(const char* name, QOS = QOS::Default);
+    WTF_EXPORT_PRIVATE static void apply(size_t iterations, WTF::Function<void(size_t index)>&&);
+private:
+    ConcurrentWorkQueue(const char* name, QOS qos)
+        : WorkQueueBase(name, Type::Concurrent, qos)
+    {
+    }
+};
+
 }
 
 using WTF::WorkQueue;
+using WTF::ConcurrentWorkQueue;

Modified: trunk/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp (284134 => 284135)


--- trunk/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -35,7 +35,7 @@
 
 struct DispatchWorkItem {
     WTF_MAKE_STRUCT_FAST_ALLOCATED;
-    Ref<WorkQueue> m_workQueue;
+    Ref<WorkQueueBase> m_workQueue;
     Function<void()> m_function;
     void operator()() { m_function(); }
 };
@@ -49,32 +49,27 @@
     delete item;
 }
 
-void WorkQueue::dispatch(Function<void()>&& function)
+void WorkQueueBase::dispatch(Function<void()>&& function)
 {
     dispatch_async_f(m_dispatchQueue.get(), new DispatchWorkItem { Ref { *this }, WTFMove(function) }, dispatchWorkItem<DispatchWorkItem>);
 }
 
-void WorkQueue::dispatchAfter(Seconds duration, Function<void()>&& function)
+void WorkQueueBase::dispatchAfter(Seconds duration, Function<void()>&& function)
 {
     dispatch_after_f(dispatch_time(DISPATCH_TIME_NOW, duration.nanosecondsAs<int64_t>()), m_dispatchQueue.get(), new DispatchWorkItem { Ref { *this },  WTFMove(function) }, dispatchWorkItem<DispatchWorkItem>);
 }
 
-void WorkQueue::dispatchSync(Function<void()>&& function)
+void WorkQueueBase::dispatchSync(Function<void()>&& function)
 {
     dispatch_sync_f(m_dispatchQueue.get(), new Function<void()> { WTFMove(function) }, dispatchWorkItem<Function<void()>>);
 }
 
-Ref<WorkQueue> WorkQueue::constructMainWorkQueue()
-{
-    return adoptRef(*new WorkQueue(dispatch_get_main_queue()));
-}
-
-WorkQueue::WorkQueue(OSObjectPtr<dispatch_queue_t>&& dispatchQueue)
+WorkQueueBase::WorkQueueBase(OSObjectPtr<dispatch_queue_t>&& dispatchQueue)
     : m_dispatchQueue(WTFMove(dispatchQueue))
 {
 }
 
-void WorkQueue::platformInitialize(const char* name, Type type, QOS qos)
+void WorkQueueBase::platformInitialize(const char* name, Type type, QOS qos)
 {
     dispatch_queue_attr_t attr = type == Type::Concurrent ? DISPATCH_QUEUE_CONCURRENT : DISPATCH_QUEUE_SERIAL;
     attr = dispatch_queue_attr_make_with_qos_class(attr, Thread::dispatchQOSClass(qos), 0);
@@ -82,12 +77,22 @@
     dispatch_set_context(m_dispatchQueue.get(), this);
 }
 
-void WorkQueue::platformInvalidate()
+void WorkQueueBase::platformInvalidate()
 {
 }
 
-void WorkQueue::concurrentApply(size_t iterations, WTF::Function<void(size_t index)>&& function)
+WorkQueue::WorkQueue(OSObjectPtr<dispatch_queue_t>&& queue)
+    : WorkQueueBase(WTFMove(queue))
 {
+}
+
+Ref<WorkQueue> WorkQueue::constructMainWorkQueue()
+{
+    return adoptRef(*new WorkQueue(dispatch_get_main_queue()));
+}
+
+void ConcurrentWorkQueue::apply(size_t iterations, WTF::Function<void(size_t index)>&& function)
+{
     dispatch_apply(iterations, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), makeBlockPtr([function = WTFMove(function)](size_t index) {
         function(index);
     }).get());

Modified: trunk/Source/WTF/wtf/generic/WorkQueueGeneric.cpp (284134 => 284135)


--- trunk/Source/WTF/wtf/generic/WorkQueueGeneric.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WTF/wtf/generic/WorkQueueGeneric.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -32,17 +32,14 @@
 
 #include <wtf/threads/BinarySemaphore.h>
 
-Ref<WorkQueue> WorkQueue::constructMainWorkQueue()
-{
-    return adoptRef(*new WorkQueue(RunLoop::main()));
-}
+namespace WTF {
 
-WorkQueue::WorkQueue(RunLoop& runLoop)
+WorkQueueBase::WorkQueueBase(RunLoop& runLoop)
     : m_runLoop(&runLoop)
 {
 }
 
-void WorkQueue::platformInitialize(const char* name, Type, QOS)
+void WorkQueueBase::platformInitialize(const char* name, Type, QOS)
 {
     BinarySemaphore semaphore;
     Thread::create(name, [&] {
@@ -53,7 +50,7 @@
     semaphore.wait();
 }
 
-void WorkQueue::platformInvalidate()
+void WorkQueueBase::platformInvalidate()
 {
     if (m_runLoop) {
         Ref<RunLoop> protector(*m_runLoop);
@@ -64,18 +61,28 @@
     }
 }
 
-void WorkQueue::dispatch(Function<void()>&& function)
+void WorkQueueBase::dispatch(Function<void()>&& function)
 {
-    RefPtr<WorkQueue> protect(this);
-    m_runLoop->dispatch([protect, function = WTFMove(function)] {
+    m_runLoop->dispatch([protectedThis = Ref { *this }, function = WTFMove(function)] {
         function();
     });
 }
 
-void WorkQueue::dispatchAfter(Seconds delay, Function<void()>&& function)
+void WorkQueueBase::dispatchAfter(Seconds delay, Function<void()>&& function)
 {
-    RefPtr<WorkQueue> protect(this);
-    m_runLoop->dispatchAfter(delay, [protect, function = WTFMove(function)] {
+    m_runLoop->dispatchAfter(delay, [protectedThis = Ref { *this }, function = WTFMove(function)] {
         function();
     });
 }
+
+WorkQueue::WorkQueue(RunLoop& loop)
+    : WorkQueueBase(loop)
+{
+}
+
+Ref<WorkQueue> WorkQueue::constructMainWorkQueue()
+{
+    return adoptRef(*new WorkQueue(RunLoop::main()));
+}
+
+}

Modified: trunk/Source/WebCore/ChangeLog (284134 => 284135)


--- trunk/Source/WebCore/ChangeLog	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebCore/ChangeLog	2021-10-14 00:09:18 UTC (rev 284135)
@@ -1,3 +1,36 @@
+2021-10-13  Jean-Yves Avenard  <[email protected]>
+
+        Clearly distinguish serial from concurrent WorkQueue
+        https://bugs.webkit.org/show_bug.cgi?id=231418
+        rdar://problem/84021977
+
+        Reviewed by Chris Dumez.
+
+        Replace instances of WorkQueue being constructed as a concurrent one
+        with ConcurrentWorkQueue.
+        Remove the now unnecessary use of WorkQueue::Type::Serial in constructor.
+
+        Fly-by fix: make use of NeverDestroyed in some methods.
+
+        No change in observable behaviour.
+
+        * platform/graphics/ImageSource.cpp:
+        (WebCore::ImageSource::decodingQueue):
+        * platform/graphics/filters/FEConvolveMatrix.cpp:
+        (WebCore::FEConvolveMatrix::platformApplySoftware):
+        * platform/mediastream/libwebrtc/LibWebRTCAudioModule.cpp:
+        (WebCore::LibWebRTCAudioModule::LibWebRTCAudioModule):
+        * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
+        (WebCore::MockRealtimeVideoSourceMac::MockRealtimeVideoSourceMac):
+        * platform/network/BlobRegistryImpl.cpp:
+        (WebCore::blobUtilityQueue):
+        * platform/network/DataURLDecoder.cpp:
+        (WebCore::DataURLDecoder::decodeQueue):
+        * storage/StorageQuotaManager.cpp:
+        (WebCore::StorageQuotaManager::StorageQuotaManager):
+        * workers/service/server/RegistrationDatabase.cpp:
+        (WebCore::registrationDatabaseWorkQueue):
+
 2021-10-13  Alan Bujtas  <[email protected]>
 
         [LFC][IFC] Preserved tab is not a word separator

Modified: trunk/Source/WebCore/platform/graphics/ImageSource.cpp (284134 => 284135)


--- trunk/Source/WebCore/platform/graphics/ImageSource.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebCore/platform/graphics/ImageSource.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -323,7 +323,7 @@
 WorkQueue& ImageSource::decodingQueue()
 {
     if (!m_decodingQueue)
-        m_decodingQueue = WorkQueue::create("org.webkit.ImageDecoder", WorkQueue::Type::Serial, WorkQueue::QOS::Default);
+        m_decodingQueue = WorkQueue::create("org.webkit.ImageDecoder", WorkQueue::QOS::Default);
 
     return *m_decodingQueue;
 }

Modified: trunk/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp (284134 => 284135)


--- trunk/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -413,7 +413,7 @@
         int stride = clipBottom / iterations;
         int chunkCount = (clipBottom + stride - 1) / stride;
 
-        WorkQueue::concurrentApply(chunkCount, [&](size_t index) {
+        ConcurrentWorkQueue::apply(chunkCount, [&](size_t index) {
             int yStart = (stride * index);
             int yEnd = std::min<int>(stride * (index + 1), clipBottom);
 

Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCAudioModule.cpp (284134 => 284135)


--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCAudioModule.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCAudioModule.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -35,7 +35,7 @@
 namespace WebCore {
 
 LibWebRTCAudioModule::LibWebRTCAudioModule()
-    : m_queue(WorkQueue::create("WebKitWebRTCAudioModule", WorkQueue::Type::Serial, WorkQueue::QOS::UserInteractive))
+    : m_queue(WorkQueue::create("WebKitWebRTCAudioModule", WorkQueue::QOS::UserInteractive))
     , m_logTimer(*this, &LibWebRTCAudioModule::logTimerFired)
 {
 }

Modified: trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm (284134 => 284135)


--- trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm	2021-10-14 00:09:18 UTC (rev 284135)
@@ -77,7 +77,7 @@
 
 MockRealtimeVideoSourceMac::MockRealtimeVideoSourceMac(String&& deviceID, String&& name, String&& hashSalt)
     : MockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
-    , m_workQueue(WorkQueue::create("MockRealtimeVideoSource Render Queue", WorkQueue::Type::Serial, WorkQueue::QOS::UserInteractive))
+    , m_workQueue(WorkQueue::create("MockRealtimeVideoSource Render Queue", WorkQueue::QOS::UserInteractive))
 {
 }
 

Modified: trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp (284134 => 284135)


--- trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -252,7 +252,7 @@
 
 static WorkQueue& blobUtilityQueue()
 {
-    static auto& queue = WorkQueue::create("org.webkit.BlobUtility", WorkQueue::Type::Serial, WorkQueue::QOS::Utility).leakRef();
+    static auto& queue = WorkQueue::create("org.webkit.BlobUtility", WorkQueue::QOS::Utility).leakRef();
     return queue;
 }
 

Modified: trunk/Source/WebCore/platform/network/DataURLDecoder.cpp (284134 => 284135)


--- trunk/Source/WebCore/platform/network/DataURLDecoder.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebCore/platform/network/DataURLDecoder.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -62,7 +62,7 @@
 
 static WorkQueue& decodeQueue()
 {
-    static auto& queue = WorkQueue::create("org.webkit.DataURLDecoder", WorkQueue::Type::Serial, WorkQueue::QOS::UserInitiated).leakRef();
+    static auto& queue = WorkQueue::create("org.webkit.DataURLDecoder", WorkQueue::QOS::UserInitiated).leakRef();
     return queue;
 }
 

Modified: trunk/Source/WebCore/storage/StorageQuotaManager.cpp (284134 => 284135)


--- trunk/Source/WebCore/storage/StorageQuotaManager.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebCore/storage/StorageQuotaManager.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -42,7 +42,7 @@
     : m_quota(quota)
     , m_usageGetter(WTFMove(usageGetter))
     , m_quotaIncreaseRequester(WTFMove(quotaIncreaseRequester))
-    , m_workQueue(WorkQueue::create("StorageQuotaManager Background Queue", WorkQueue::Type::Serial))
+    , m_workQueue(WorkQueue::create("StorageQuotaManager Background Queue"))
     , m_initialQuota(quota)
 {
 }

Modified: trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp (284134 => 284135)


--- trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -157,7 +157,7 @@
     static LazyNeverDestroyed<Ref<WorkQueue>> workQueue;
     static std::once_flag onceKey;
     std::call_once(onceKey, [] {
-        workQueue.construct(WorkQueue::create("ServiceWorker I/O Thread", WorkQueue::Type::Serial));
+        workQueue.construct(WorkQueue::create("ServiceWorker I/O Thread"));
     });
     return workQueue;
 }

Modified: trunk/Source/WebKit/ChangeLog (284134 => 284135)


--- trunk/Source/WebKit/ChangeLog	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/ChangeLog	2021-10-14 00:09:18 UTC (rev 284135)
@@ -1,3 +1,56 @@
+2021-10-13  Jean-Yves Avenard  <[email protected]>
+
+        Clearly distinguish serial from concurrent WorkQueue
+        https://bugs.webkit.org/show_bug.cgi?id=231418
+        rdar://problem/84021977
+
+        Reviewed by Chris Dumez.
+
+        Replace instances of WorkQueue being constructed as a concurrent one
+        with ConcurrentWorkQueue.
+        Remove the now unnecessary use of WorkQueue::Type::Serial in constructor.
+
+        * GPUProcess/GPUProcess.cpp:
+        (WebKit::GPUProcess::videoMediaStreamTrackRendererQueue):
+        (WebKit::GPUProcess::libWebRTCCodecsQueue):
+        * NetworkProcess/cache/CacheStorageEngine.cpp:
+        (WebKit::CacheStorage::Engine::Engine):
+        * NetworkProcess/cache/NetworkCacheIOChannel.h:
+        * NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm:
+        (WebKit::NetworkCache::IOChannel::read):
+        (WebKit::NetworkCache::IOChannel::write):
+        * NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp:
+        (WebKit::NetworkCache::IOChannel::read):
+        (WebKit::NetworkCache::IOChannel::write):
+        * NetworkProcess/cache/NetworkCacheIOChannelGLib.cpp:
+        (WebKit::NetworkCache::IOChannel::read):
+        (WebKit::NetworkCache::IOChannel::readSyncInThread):
+        (WebKit::NetworkCache::IOChannel::write):
+        * NetworkProcess/cache/NetworkCacheStorage.cpp:
+        (WebKit::NetworkCache::Storage::Storage):
+        * NetworkProcess/cache/NetworkCacheStorage.h:
+        (WebKit::NetworkCache::Storage::ioQueue):
+        (WebKit::NetworkCache::Storage::backgroundIOQueue):
+        * Platform/IPC/cocoa/ConnectionCocoa.mm:
+        (IPC::Connection::open):
+        * Shared/mac/MediaFormatReader/MediaFormatReader.cpp:
+        (WebKit::readerQueue):
+        * Shared/mac/MediaFormatReader/MediaTrackReader.cpp:
+        (WebKit::MediaTrackReader::storageQueue):
+        * UIProcess/API/APIContentRuleListStore.cpp:
+        (API::ContentRuleListStore::ContentRuleListStore):
+        * UIProcess/API/APIContentRuleListStore.h:
+        * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+        (WebKit::appBoundDomainQueue):
+        * WebProcess/GPU/media/RemoteAudioSourceProviderManager.cpp:
+        (WebKit::RemoteAudioSourceProviderManager::RemoteAudioSourceProviderManager):
+        * WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp:
+        (WebKit::LibWebRTCCodecs::LibWebRTCCodecs):
+        * WebProcess/WebPage/EventDispatcher.cpp:
+        (WebKit::EventDispatcher::EventDispatcher):
+        * WebProcess/cocoa/RemoteCaptureSampleManager.cpp:
+        (WebKit::RemoteCaptureSampleManager::RemoteCaptureSampleManager):
+
 2021-10-13  Adrian Perez de Castro  <[email protected]>
 
         [GTK] Opening emoji chooser crashes UI process with GTK 3.24.30

Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.cpp (284134 => 284135)


--- trunk/Source/WebKit/GPUProcess/GPUProcess.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -420,7 +420,7 @@
 WorkQueue& GPUProcess::videoMediaStreamTrackRendererQueue()
 {
     if (!m_videoMediaStreamTrackRendererQueue)
-        m_videoMediaStreamTrackRendererQueue = WorkQueue::create("RemoteVideoMediaStreamTrackRenderer", WorkQueue::Type::Serial, WorkQueue::QOS::UserInitiated);
+        m_videoMediaStreamTrackRendererQueue = WorkQueue::create("RemoteVideoMediaStreamTrackRenderer", WorkQueue::QOS::UserInitiated);
     return *m_videoMediaStreamTrackRendererQueue;
 }
 #endif
@@ -429,7 +429,7 @@
 WorkQueue& GPUProcess::libWebRTCCodecsQueue()
 {
     if (!m_libWebRTCCodecsQueue)
-        m_libWebRTCCodecsQueue = WorkQueue::create("LibWebRTCCodecsQueue", WorkQueue::Type::Serial, WorkQueue::QOS::UserInitiated);
+        m_libWebRTCCodecsQueue = WorkQueue::create("LibWebRTCCodecsQueue", WorkQueue::QOS::UserInitiated);
     return *m_libWebRTCCodecsQueue;
 }
 #endif

Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp (284134 => 284135)


--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -264,7 +264,7 @@
     , m_rootPath(WTFMove(rootPath))
 {
     if (!m_rootPath.isNull())
-        m_ioQueue = WorkQueue::create("com.apple.WebKit.CacheStorageEngine.serial.default", WorkQueue::Type::Serial, WorkQueue::QOS::Default);
+        m_ioQueue = WorkQueue::create("com.apple.WebKit.CacheStorageEngine.serial.default", WorkQueue::QOS::Default);
 }
 
 void Engine::open(const WebCore::ClientOrigin& origin, const String& cacheName, CacheIdentifierCallback&& callback)

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannel.h (284134 => 284135)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannel.h	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannel.h	2021-10-14 00:09:18 UTC (rev 284135)
@@ -49,8 +49,9 @@
 
     // Using nullptr as queue submits the result to the main queue.
     // FIXME: We should add WorkQueue::main() instead.
-    void read(size_t offset, size_t, WorkQueue&, Function<void (Data&, int error)>&&);
-    void write(size_t offset, const Data&, WorkQueue&, Function<void (int error)>&&);
+    // Can be used with either a concurrent WorkQueue or a serial one.
+    void read(size_t offset, size_t, WTF::WorkQueueBase&, Function<void(Data&, int error)>&&);
+    void write(size_t offset, const Data&, WTF::WorkQueueBase&, Function<void(int error)>&&);
 
     const String& path() const { return m_path; }
     Type type() const { return m_type; }
@@ -67,7 +68,7 @@
     IOChannel(String&& filePath, IOChannel::Type, std::optional<WorkQueue::QOS>);
 
 #if USE(GLIB)
-    void readSyncInThread(size_t offset, size_t, WorkQueue&, Function<void (Data&, int error)>&&);
+    void readSyncInThread(size_t offset, size_t, WTF::WorkQueueBase&, Function<void(Data&, int error)>&&);
 #endif
 
     String m_path;

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm (284134 => 284135)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm	2021-10-14 00:09:18 UTC (rev 284135)
@@ -96,7 +96,7 @@
     RELEASE_ASSERT(!m_wasDeleted.exchange(true));
 }
 
-void IOChannel::read(size_t offset, size_t size, WorkQueue& queue, Function<void (Data&, int error)>&& completionHandler)
+void IOChannel::read(size_t offset, size_t size, WTF::WorkQueueBase& queue, Function<void(Data&, int error)>&& completionHandler)
 {
     RefPtr<IOChannel> channel(this);
     bool didCallCompletionHandler = false;
@@ -111,7 +111,7 @@
     }).get());
 }
 
-void IOChannel::write(size_t offset, const Data& data, WorkQueue& queue, Function<void (int error)>&& completionHandler)
+void IOChannel::write(size_t offset, const Data& data, WTF::WorkQueueBase& queue, Function<void(int error)>&& completionHandler)
 {
     RefPtr<IOChannel> channel(this);
     auto dispatchData = data.dispatchData();

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp (284134 => 284135)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -55,7 +55,7 @@
     FileSystem::closeFile(m_fileDescriptor);
 }
 
-void IOChannel::read(size_t offset, size_t size, WorkQueue& queue, Function<void(Data&, int error)>&& completionHandler)
+void IOChannel::read(size_t offset, size_t size, WTF::WorkQueueBase& queue, Function<void(Data&, int error)>&& completionHandler)
 {
     queue.dispatch([this, protectedThis = Ref { *this }, offset, size, completionHandler = WTFMove(completionHandler)] {
         auto fileSize = FileSystem::fileSize(m_fileDescriptor);
@@ -75,7 +75,7 @@
     });
 }
 
-void IOChannel::write(size_t offset, const Data& data, WorkQueue& queue, Function<void(int error)>&& completionHandler)
+void IOChannel::write(size_t offset, const Data& data, WTF::WorkQueueBase& queue, Function<void(int error)>&& completionHandler)
 {
     queue.dispatch([this, protectedThis = Ref { *this }, offset, data, completionHandler = WTFMove(completionHandler)] {
         FileSystem::seekFile(m_fileDescriptor, offset, FileSystem::FileSeekOrigin::Beginning);

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelGLib.cpp (284134 => 284135)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelGLib.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelGLib.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -92,7 +92,7 @@
 
     RefPtr<IOChannel> channel;
     GRefPtr<GBytes> buffer;
-    Ref<WorkQueue> queue;
+    Ref<WTF::WorkQueueBase> queue;
     size_t bytesToRead;
     Function<void(Data&, int error)> completionHandler;
     Data data;
@@ -134,7 +134,7 @@
         reinterpret_cast<GAsyncReadyCallback>(inputStreamReadReadyCallback), asyncData.release());
 }
 
-void IOChannel::read(size_t offset, size_t size, WorkQueue& queue, Function<void(Data&, int error)>&& completionHandler)
+void IOChannel::read(size_t offset, size_t size, WTF::WorkQueueBase& queue, Function<void(Data&, int error)>&& completionHandler)
 {
     RefPtr<IOChannel> protectedThis(this);
     if (!m_inputStream) {
@@ -160,7 +160,7 @@
         reinterpret_cast<GAsyncReadyCallback>(inputStreamReadReadyCallback), asyncData);
 }
 
-void IOChannel::readSyncInThread(size_t offset, size_t size, WorkQueue& queue, Function<void(Data&, int error)>&& completionHandler)
+void IOChannel::readSyncInThread(size_t offset, size_t size, WTF::WorkQueueBase& queue, Function<void(Data&, int error)>&& completionHandler)
 {
     ASSERT(!RunLoop::isMain());
 
@@ -204,7 +204,7 @@
 
     RefPtr<IOChannel> channel;
     GRefPtr<GBytes> buffer;
-    Ref<WorkQueue> queue;
+    Ref<WTF::WorkQueueBase> queue;
     Function<void(int error)> completionHandler;
 };
 
@@ -234,7 +234,7 @@
         reinterpret_cast<GAsyncReadyCallback>(outputStreamWriteReadyCallback), asyncData.release());
 }
 
-void IOChannel::write(size_t offset, const Data& data, WorkQueue& queue, Function<void(int error)>&& completionHandler)
+void IOChannel::write(size_t offset, const Data& data, WTF::WorkQueueBase& queue, Function<void(int error)>&& completionHandler)
 {
     RefPtr<IOChannel> protectedThis(this);
     if (!m_outputStream && !m_ioStream) {

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp (284134 => 284135)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -269,9 +269,9 @@
     , m_capacity(capacity)
     , m_readOperationTimeoutTimer(*this, &Storage::cancelAllReadOperations)
     , m_writeOperationDispatchTimer(*this, &Storage::dispatchPendingWriteOperations)
-    , m_ioQueue(WorkQueue::create("com.apple.WebKit.Cache.Storage", WorkQueue::Type::Concurrent))
-    , m_backgroundIOQueue(WorkQueue::create("com.apple.WebKit.Cache.Storage.background", WorkQueue::Type::Concurrent, WorkQueue::QOS::Background))
-    , m_serialBackgroundIOQueue(WorkQueue::create("com.apple.WebKit.Cache.Storage.serialBackground", WorkQueue::Type::Serial, WorkQueue::QOS::Background))
+    , m_ioQueue(ConcurrentWorkQueue::create("com.apple.WebKit.Cache.Storage"))
+    , m_backgroundIOQueue(ConcurrentWorkQueue::create("com.apple.WebKit.Cache.Storage.background", WorkQueue::QOS::Background))
+    , m_serialBackgroundIOQueue(WorkQueue::create("com.apple.WebKit.Cache.Storage.serialBackground", WorkQueue::QOS::Background))
     , m_blobStorage(makeBlobDirectoryPath(baseDirectoryPath), m_salt)
 {
     ASSERT(RunLoop::isMain());

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h (284134 => 284135)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h	2021-10-14 00:09:18 UTC (rev 284135)
@@ -150,8 +150,8 @@
     void updateFileModificationTime(const String& path);
     void removeFromPendingWriteOperations(const Key&);
 
-    WorkQueue& ioQueue() { return m_ioQueue.get(); }
-    WorkQueue& backgroundIOQueue() { return m_backgroundIOQueue.get(); }
+    ConcurrentWorkQueue& ioQueue() { return m_ioQueue.get(); }
+    ConcurrentWorkQueue& backgroundIOQueue() { return m_backgroundIOQueue.get(); }
     WorkQueue& serialBackgroundIOQueue() { return m_serialBackgroundIOQueue.get(); }
 
     bool mayContain(const Key&) const;
@@ -198,8 +198,8 @@
     struct TraverseOperation;
     HashSet<std::unique_ptr<TraverseOperation>> m_activeTraverseOperations;
 
-    Ref<WorkQueue> m_ioQueue;
-    Ref<WorkQueue> m_backgroundIOQueue;
+    Ref<ConcurrentWorkQueue> m_ioQueue;
+    Ref<ConcurrentWorkQueue> m_backgroundIOQueue;
     Ref<WorkQueue> m_serialBackgroundIOQueue;
 
     BlobStorage m_blobStorage;

Modified: trunk/Source/WebKit/Platform/IPC/cocoa/ConnectionCocoa.mm (284134 => 284135)


--- trunk/Source/WebKit/Platform/IPC/cocoa/ConnectionCocoa.mm	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/Platform/IPC/cocoa/ConnectionCocoa.mm	2021-10-14 00:09:18 UTC (rev 284135)
@@ -237,14 +237,11 @@
         mach_port_mod_refs(mach_task_self(), receivePort, MACH_PORT_RIGHT_RECEIVE, -1);
     });
 
-    ref();
-    dispatch_async(m_connectionQueue->dispatchQueue(), ^{
+    m_connectionQueue->dispatch([strongRef = Ref { *this }, this] {
         dispatch_resume(m_receiveSource.get());
 
         if (m_sendSource)
             dispatch_resume(m_sendSource.get());
-
-        deref();
     });
 
     return true;

Modified: trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaFormatReader.cpp (284134 => 284135)


--- trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaFormatReader.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaFormatReader.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -39,6 +39,7 @@
 #include <WebCore/VideoTrackPrivate.h>
 #include <pal/avfoundation/MediaTimeAVFoundation.h>
 #include <wtf/LoggerHelper.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/WorkQueue.h>
 
 #include <pal/cocoa/MediaToolboxSoftLink.h>
@@ -120,10 +121,10 @@
     });
 }
 
-static WorkQueue& readerQueue()
+static ConcurrentWorkQueue& readerQueue()
 {
-    static auto& queue = WorkQueue::create("WebKit::MediaFormatReader Queue", WorkQueue::Type::Concurrent).leakRef();
-    return queue;
+    static NeverDestroyed<Ref<ConcurrentWorkQueue>> queue = ConcurrentWorkQueue::create("WebKit::MediaFormatReader Queue");
+    return queue.get();
 }
 
 void MediaFormatReader::parseByteSource(RetainPtr<MTPluginByteSourceRef>&& byteSource)

Modified: trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaTrackReader.cpp (284134 => 284135)


--- trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaTrackReader.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaTrackReader.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -39,6 +39,7 @@
 #include <WebCore/VideoTrackPrivate.h>
 #include <pal/avfoundation/MediaTimeAVFoundation.h>
 #include <wtf/LoggerHelper.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/WorkQueue.h>
 
 #include <pal/cocoa/MediaToolboxSoftLink.h>
@@ -66,8 +67,8 @@
 
 WorkQueue& MediaTrackReader::storageQueue()
 {
-    static auto& queue = WorkQueue::create("WebKit::MediaTrackReader Storage Queue", WorkQueue::Type::Serial).leakRef();
-    return queue;
+    static NeverDestroyed<Ref<WorkQueue>> queue = WorkQueue::create("WebKit::MediaFormatReader Queue");
+    return queue.get();
 }
 
 MediaTrackReader::MediaTrackReader(Allocator&& allocator, const MediaFormatReader& formatReader, CMMediaType mediaType, uint64_t trackID, std::optional<bool> enabled)

Modified: trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp (284134 => 284135)


--- trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -70,7 +70,7 @@
 
 ContentRuleListStore::ContentRuleListStore(const WTF::String& storePath)
     : m_storePath(storePath)
-    , m_compileQueue(WorkQueue::create("ContentRuleListStore Compile Queue", WorkQueue::Type::Concurrent))
+    , m_compileQueue(ConcurrentWorkQueue::create("ContentRuleListStore Compile Queue"))
     , m_readQueue(WorkQueue::create("ContentRuleListStore Read Queue"))
     , m_removeQueue(WorkQueue::create("ContentRuleListStore Remove Queue"))
 {

Modified: trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.h (284134 => 284135)


--- trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.h	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.h	2021-10-14 00:09:18 UTC (rev 284135)
@@ -36,6 +36,7 @@
 }
 
 namespace WTF {
+class ConcurrentWorkQueue;
 class WorkQueue;
 }
 
@@ -80,7 +81,7 @@
     WTF::String defaultStorePath();
     
     const WTF::String m_storePath;
-    Ref<WTF::WorkQueue> m_compileQueue;
+    Ref<WTF::ConcurrentWorkQueue> m_compileQueue;
     Ref<WTF::WorkQueue> m_readQueue;
     Ref<WTF::WorkQueue> m_removeQueue;
 };

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm (284134 => 284135)


--- trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm	2021-10-14 00:09:18 UTC (rev 284135)
@@ -71,7 +71,7 @@
 #if ENABLE(APP_BOUND_DOMAINS)
 static WorkQueue& appBoundDomainQueue()
 {
-    static auto& queue = WorkQueue::create("com.apple.WebKit.AppBoundDomains", WorkQueue::Type::Serial).leakRef();
+    static auto& queue = WorkQueue::create("com.apple.WebKit.AppBoundDomains").leakRef();
     return queue;
 }
 static std::atomic<bool> hasInitializedAppBoundDomains = false;

Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSourceProviderManager.cpp (284134 => 284135)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSourceProviderManager.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSourceProviderManager.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -39,7 +39,7 @@
 using namespace WebCore;
 
 RemoteAudioSourceProviderManager::RemoteAudioSourceProviderManager()
-    : m_queue(WorkQueue::create("RemoteAudioSourceProviderManager", WorkQueue::Type::Serial, WorkQueue::QOS::UserInteractive))
+    : m_queue(WorkQueue::create("RemoteAudioSourceProviderManager", WorkQueue::QOS::UserInteractive))
 {
 }
 

Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp (284134 => 284135)


--- trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -171,7 +171,7 @@
 }
 
 LibWebRTCCodecs::LibWebRTCCodecs()
-    : m_queue(WorkQueue::create("LibWebRTCCodecs", WorkQueue::Type::Serial, WorkQueue::QOS::UserInteractive))
+    : m_queue(WorkQueue::create("LibWebRTCCodecs", WorkQueue::QOS::UserInteractive))
 {
 }
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp (284134 => 284135)


--- trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -60,7 +60,7 @@
 }
 
 EventDispatcher::EventDispatcher()
-    : m_queue(WorkQueue::create("com.apple.WebKit.EventDispatcher", WorkQueue::Type::Serial, WorkQueue::QOS::UserInteractive))
+    : m_queue(WorkQueue::create("com.apple.WebKit.EventDispatcher", WorkQueue::QOS::UserInteractive))
     , m_recentWheelEventDeltaFilter(WheelEventDeltaFilter::create())
 {
 }

Modified: trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.cpp (284134 => 284135)


--- trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -40,7 +40,7 @@
 using namespace WebCore;
 
 RemoteCaptureSampleManager::RemoteCaptureSampleManager()
-    : m_queue(WorkQueue::create("RemoteCaptureSampleManager", WorkQueue::Type::Serial, WorkQueue::QOS::UserInteractive))
+    : m_queue(WorkQueue::create("RemoteCaptureSampleManager", WorkQueue::QOS::UserInteractive))
 {
 }
 

Modified: trunk/Tools/ChangeLog (284134 => 284135)


--- trunk/Tools/ChangeLog	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Tools/ChangeLog	2021-10-14 00:09:18 UTC (rev 284135)
@@ -1,3 +1,14 @@
+2021-10-13  Jean-Yves Avenard  <[email protected]>
+
+        Clearly distinguish serial from concurrent WorkQueue
+        https://bugs.webkit.org/show_bug.cgi?id=231418
+        rdar://problem/84021977
+
+        Reviewed by Chris Dumez.
+
+        * TestWebKitAPI/Tests/WTF/WorkQueue.cpp:
+        (TestWebKitAPI::TEST):
+
 2021-10-13  Ryan Haddad  <[email protected]>
 
         Disable failing API tests

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/WorkQueue.cpp (284134 => 284135)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/WorkQueue.cpp	2021-10-13 23:04:57 UTC (rev 284134)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/WorkQueue.cpp	2021-10-14 00:09:18 UTC (rev 284135)
@@ -300,7 +300,7 @@
     constexpr size_t iterationCount = 10000;
     RefPtr<WorkQueue> queue[queueCount];
     for (size_t i = 0; i < queueCount; ++i)
-        queue[i] = WorkQueue::create("com.apple.WebKit.Test.destroyDispatchedOnDispatchQueue", WorkQueue::Type::Serial, WorkQueue::QOS::UserInteractive);
+        queue[i] = WorkQueue::create("com.apple.WebKit.Test.destroyDispatchedOnDispatchQueue", WorkQueue::QOS::UserInteractive);
 
     for (size_t i = 0; i < iterationCount; ++i) {
         for (size_t j = 0; j < queueCount; ++j)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to