[WTF] Add WorkerPool
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jun 2018 08:47:06 +0000 (08:47 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jun 2018 08:47:06 +0000 (08:47 +0000)
commitf517e32285c89e7051301dcc746170e2b013089f
treed1757cb8cc0ea99fae1c6f2809e335b47f431a82
parentdfa9c7afde07396d4822f7f9b024440d4c932934
[WTF] Add WorkerPool
https://bugs.webkit.org/show_bug.cgi?id=174569

Reviewed by Carlos Garcia Campos.

Source/WebCore:

We start using WorkerPool for NicosiaPaintingEngineThreaded instead of glib thread pool.
This makes NicosiaPaintingEngineThreaded platform-independent and usable for WinCairo.

* platform/graphics/nicosia/NicosiaPaintingEngineThreaded.cpp:
(Nicosia::PaintingEngineThreaded::PaintingEngineThreaded):
(Nicosia::PaintingEngineThreaded::~PaintingEngineThreaded):
(Nicosia::PaintingEngineThreaded::paint):
(Nicosia::s_threadFunc): Deleted.
* platform/graphics/nicosia/NicosiaPaintingEngineThreaded.h:

Source/WTF:

This patch adds WorkerPool, which is a thread pool that consists of AutomaticThread.
Since it is based on AutomaticThread, this WorkerPool can take `timeout`: once `timeout`
passes without any tasks, threads in WorkerPool will be destroyed.

We add shouldSleep handler to AutomaticThread to make destruction of threads in WorkerPool moderate.
Without this, all threads are destroyed at once after `timeout` passes.

* WTF.xcodeproj/project.pbxproj:
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::AutomaticThread):
(WTF::AutomaticThread::start):
* wtf/AutomaticThread.h:
* wtf/CMakeLists.txt:
* wtf/WorkerPool.cpp: Added.
(WTF::WorkerPool::WorkerPool):
(WTF::WorkerPool::~WorkerPool):
(WTF::WorkerPool::shouldSleep):
(WTF::WorkerPool::postTask):
* wtf/WorkerPool.h: Added.
(WTF::WorkerPool::create):

Tools:

* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/WorkerPool.cpp: Added.
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232619 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/AutomaticThread.cpp
Source/WTF/wtf/AutomaticThread.h
Source/WTF/wtf/CMakeLists.txt
Source/WTF/wtf/WorkerPool.cpp [new file with mode: 0644]
Source/WTF/wtf/WorkerPool.h [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/nicosia/NicosiaPaintingEngineThreaded.cpp
Source/WebCore/platform/graphics/nicosia/NicosiaPaintingEngineThreaded.h
Tools/ChangeLog
Tools/TestWebKitAPI/CMakeLists.txt
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WTF/WorkerPool.cpp [new file with mode: 0644]