20#if defined(SK_BUILD_FOR_WIN)
24 GetNativeSystemInfo(&sysinfo);
25 return (
int)sysinfo.dwNumberOfProcessors;
30 return (
int)sysconf(_SC_NPROCESSORS_ONLN);
74template <
typename WorkList>
77 explicit SkThreadPool(
int threads,
bool allowBorrowing) : fAllowBorrowing(allowBorrowing) {
78 for (
int i = 0;
i < threads;
i++) {
85 for (
int i = 0;
i < fThreads.
size();
i++) {
89 for (
int i = 0;
i < fThreads.
size();
i++) {
98 fWork.emplace_back(std::move(work));
106 if (fAllowBorrowing && fWorkAvailable.
try_wait()) {
129 static void Loop(
void* ctx) {
132 pool->fWorkAvailable.wait();
133 }
while (
pool->do_work());
137 using Lock = SkMutex;
143 bool fAllowBorrowing;
148 return std::make_unique<SkThreadPool<WorkList>>(threads > 0 ? threads :
num_cores(),
153 return std::make_unique<SkThreadPool<WorkList>>(threads > 0 ? threads :
num_cores(),
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
static SkExecutor & trivial_executor()
static std::function< void(void)> pop(std::deque< std::function< void(void)> > *list)
static SkExecutor * gDefaultExecutor
static std::unique_ptr< SkExecutor > MakeFIFOThreadPool(int threads=0, bool allowBorrowing=true)
static SkExecutor & GetDefault()
static void SetDefault(SkExecutor *)
static std::unique_ptr< SkExecutor > MakeLIFOThreadPool(int threads=0, bool allowBorrowing=true)
SkThreadPool(int threads, bool allowBorrowing)
void add(std::function< void(void)> work) override
T & emplace_back(Args &&... args)
Dart_NativeFunction function