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/jsc.cpp

    r225352 r225778  
    15611561    bool didStart = false;
    15621562   
    1563     RefPtr<Thread> thread = Thread::create(
     1563    Thread::create(
    15641564        "JSC Agent",
    15651565        [sourceCode, &didStartLock, &didStartCondition, &didStart] () {
     
    15871587                    return success;
    15881588                });
    1589         });
    1590     thread->detach();
     1589        })->detach();
    15911590   
    15921591    {
Note: See TracChangeset for help on using the changeset viewer.