Ignore:
Timestamp:
Dec 12, 2017, 2:35:39 AM (7 years ago)
Author:
Yusuke Suzuki
Message:

[WTF] Thread::create should have Thread::tryCreate
https://bugs.webkit.org/show_bug.cgi?id=180333

Reviewed by Darin Adler.

Source/JavaScriptCore:

  • assembler/testmasm.cpp:

(JSC::run):

  • b3/air/testair.cpp:
  • b3/testb3.cpp:

(JSC::B3::run):

  • jsc.cpp:

(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.cpp:

(WTF::AutomaticThread::start):

  • wtf/ParallelJobsGeneric.cpp:

(WTF::ParallelEnvironment::ThreadPrivate::tryLockFor):

  • wtf/Threading.cpp:

(WTF::Thread::tryCreate):
(WTF::Thread::create): Deleted.

  • wtf/Threading.h:

(WTF::Thread::create):

  • wtf/WorkQueue.cpp:

(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):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/b3/testb3.cpp

    r225659 r225778  
    1779517795    Lock lock;
    1779617796
    17797     Vector<RefPtr<Thread>> threads;
     17797    Vector<Ref<Thread>> threads;
    1779817798    for (unsigned i = filter ? 1 : WTF::numberOfProcessorCores(); i--;) {
    1779917799        threads.append(
     
    1781517815    }
    1781617816
    17817     for (RefPtr<Thread> thread : threads)
     17817    for (auto& thread : threads)
    1781817818        thread->waitForCompletion();
    1781917819    crashLock.lock();
Note: See TracChangeset for help on using the changeset viewer.