[WTF] Thread::create should have Thread::tryCreate
https://bugs.webkit.org/show_bug.cgi?id=180333
Reviewed by Darin Adler.
Source/JavaScriptCore:
(JSC::run):
- b3/air/testair.cpp:
- b3/testb3.cpp:
(JSC::B3::run):
(functionDollarAgentStart):
Source/WebCore:
No behavior change.
- bindings/js/GCController.cpp:
(WebCore::GCController::garbageCollectOnAlternateThreadForDebugging):
- platform/audio/ReverbConvolver.cpp:
(WebCore::ReverbConvolver::ReverbConvolver):
- platform/audio/ReverbConvolver.h:
- workers/WorkerThread.cpp:
(WebCore::WorkerThread::start):
Source/WebKit:
- UIProcess/API/glib/IconDatabase.cpp:
(WebKit::IconDatabase::open):
- UIProcess/linux/MemoryPressureMonitor.cpp:
(WebKit::MemoryPressureMonitor::MemoryPressureMonitor):
Source/WebKitLegacy:
- Storage/StorageThread.cpp:
(WebCore::StorageThread::start):
Source/WebKitLegacy/win:
- WebKitQuartzCoreAdditions/CVDisplayLink.cpp:
(WKQCA::CVDisplayLink::start):
Source/WTF:
Many callers of Thread::create assume that it returns non-nullptr Thread.
But if the number of threads hits the limit in the system, creating Thread
would fail. In that case, it is really difficult to keep WebKit working.
We introduce Thread::tryCreate, and change the returned value from Thread::create
from RefPtr<Thread> to Ref<Thread>. In Thread::create, we ensure thread creation
succeeds by RELEASE_ASSERT. And we use Thread::create intentionally if the
caller assumes that thread should be created.
(WTF::AutomaticThread::start):
- wtf/ParallelJobsGeneric.cpp:
(WTF::ParallelEnvironment::ThreadPrivate::tryLockFor):
(WTF::Thread::tryCreate):
(WTF::Thread::create): Deleted.
(WTF::Thread::create):
(WTF::WorkQueue::concurrentApply):
Tools:
- TestWebKitAPI/Tests/WTF/Condition.cpp:
- TestWebKitAPI/Tests/WTF/ParkingLot.cpp:
- TestWebKitAPI/Tests/WTF/Signals.cpp:
(TEST):
- TestWebKitAPI/Tests/WTF/ThreadGroup.cpp:
(TestWebKitAPI::testThreadGroup):
(TestWebKitAPI::TEST):