mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
Add a simple thread pool with a fixed number of worker threads and a shared work queue. The pool is accessed via ThreadPool::the() which lazily creates a singleton with 4 worker threads. submit() enqueues a work item and signals a condvar. Worker threads loop waiting on the condvar, picking up and executing work items. Worker threads use 8 MiB stacks to match the main thread, since the JS parser can build deep call stacks during off-thread parsing.
15 lines
378 B
CMake
15 lines
378 B
CMake
set(SOURCES
|
|
BackgroundAction.cpp
|
|
Thread.cpp
|
|
ThreadPool.cpp
|
|
)
|
|
|
|
ladybird_lib(LibThreading threading)
|
|
target_link_libraries(LibThreading PRIVATE LibCore)
|
|
|
|
if (WIN32)
|
|
find_package(pthread REQUIRED)
|
|
target_include_directories(LibThreading PUBLIC $<BUILD_INTERFACE:${PTHREAD_INCLUDE_DIR}>)
|
|
target_link_libraries(LibThreading PUBLIC ${PTHREAD_LIBRARY})
|
|
endif()
|