载入中...
搜索中...
未找到
PixelWorldThread.cpp
浏览该文件的文档.
2
3#include "thread/JobSystem.h"
4
5#include <algorithm>
6#include <memory>
7
9
12
14 std::size_t workItems, const std::function<void(std::size_t)>& body) {
15 if (workItems == 0) return;
16 try {
17 std::unique_ptr<eve::thread::Job> job(jobs_->parallelFor(
18 0, int(workItems), [&body](int first, int last) {
19 for (int index = first; index < last; ++index) body(std::size_t(index));
20 }, 1));
21 job->wait();
22 if (!job->hasFailed()) return;
23 } catch (...) {
24 // The serial pass below restores every index-owned result slot.
25 }
26 for (std::size_t index = 0; index < workItems; ++index) body(index);
27}
28
29std::size_t JobSystemPixelScheduler::workerCount() const noexcept {
30 return std::size_t(std::max(0, jobs_->getWorkerCount()));
31}
32
33} // namespace eve::pixelworld_thread
std::int32_t first
std::string body
uint32_t index
std::size_t workerCount() const noexcept override
Worker count.
JobSystemPixelScheduler(eve::thread::JobSystem &jobs) noexcept
Borrow a running scheduler.
void parallelFor(std::size_t workItems, const std::function< void(std::size_t)> &body) override
Parallel for.
Abstract job scheduler: dependencies, parallel_for, task_group, arena.
Definition JobSystem.h:157
virtual int getWorkerCount() const =0
Number of scheduler worker threads.
virtual Job * parallelFor(int first, int last, ParallelForBody body, int chunk=1)=0
Run body over [first, last) in parallel.