Default JobSystem backend: a dependency-aware scheduler over the existing ThreadPool worker pool. 更多...
#include <JobSystemThreadPool.h>
类 | |
| struct | State |
Public 成员函数 | |
| JobSystemThreadPool (int workerCount) | |
| ~JobSystemThreadPool () override | |
| JobSystemThreadPool (const JobSystemThreadPool &)=delete | |
| JobSystemThreadPool & | operator= (const JobSystemThreadPool &)=delete |
| int | getWorkerCount () const override |
| Number of scheduler worker threads. | |
| bool | isRunning () const override |
| Whether the system is still accepting new jobs. | |
| int | getPendingCount () const override |
| Number of ready jobs waiting for a worker (approximate). | |
| int | getOutstandingCount () const override |
| Number of scheduled jobs that have not finished (approximate). | |
| Job * | submit (JobFunc body) override |
| Create a job and schedule it immediately. | |
| Job * | createJob (JobFunc body) override |
| Create a paused job (dependencies can be wired, then schedule()). | |
| void | schedule (Job *job) override |
| Kick a paused job so it can run. | |
| Job * | parallelFor (int first, int last, ParallelForBody body, int chunk=1) override |
| Run body over [first, last) in parallel. | |
| TaskGroup * | createTaskGroup () override |
| Create a fork/join task group. | |
| Job * | submitFrame (JobFunc body) override |
| Create a frame-scoped job and schedule it immediately. | |
| Job * | createFrameJob (JobFunc body) override |
| Create a paused frame-scoped job. | |
| Job * | parallelForFrame (int first, int last, ParallelForBody body, int chunk=1) override |
| Frame-scoped parallel_for; see parallelFor(). | |
| TaskGroup * | createFrameTaskGroup () override |
| Create a fork/join task group whose children are frame-scoped. | |
| void | beginFrame () override |
| Start a new frame: join leftover frame jobs and recycle the arena. | |
| void | endFrame () override |
| End the frame: join outstanding frame jobs and recycle the arena. | |
| void | waitAll () override |
| Block until every scheduled job has finished. | |
| void | stop () override |
| Stop accepting work and join workers. Idempotent. | |
Public 成员函数 继承自 eve::thread::JobSystem | |
| virtual | ~JobSystem ()=default |
详细描述
Default JobSystem backend: a dependency-aware scheduler over the existing ThreadPool worker pool.
The ThreadPool keeps its FIFO + CV worker model unchanged; this class uses it purely as the worker-thread provider. Job scheduling (dependencies, ready queue, fork/join help-execution, per-frame arena) lives here, so replacing the backend with TBB does not touch any engine code that uses JobSystem.
在文件 JobSystemThreadPool.h 第 24 行定义.
构造及析构函数说明
◆ JobSystemThreadPool() [1/2]
|
explicit |
在文件 JobSystemThreadPool.cpp 第 492 行定义.
引用了 state.
◆ ~JobSystemThreadPool()
|
override |
在文件 JobSystemThreadPool.cpp 第 522 行定义.
◆ JobSystemThreadPool() [2/2]
|
delete |
成员函数说明
◆ beginFrame()
|
overridevirtual |
Start a new frame: join leftover frame jobs and recycle the arena.
All frame-scoped handles from the previous frame become invalid. Call once per frame before submitting frame jobs.
在文件 JobSystemThreadPool.cpp 第 640 行定义.
◆ createFrameJob()
Create a paused frame-scoped job.
- 参数
-
body Work to run on a worker.
- 返回
- Arena-allocated Job; do not delete, valid until next beginFrame().
在文件 JobSystemThreadPool.cpp 第 623 行定义.
引用了 body.
◆ createFrameTaskGroup()
|
overridevirtual |
Create a fork/join task group whose children are frame-scoped.
- 返回
- Arena-allocated TaskGroup; do not delete, valid until next beginFrame().
在文件 JobSystemThreadPool.cpp 第 632 行定义.
◆ createJob()
Create a paused job (dependencies can be wired, then schedule()).
- 参数
-
body Work to run on a worker; may be empty to create a pure join/dependency node that just gates downstream jobs.
- 返回
- Heap-allocated Job; delete once finished.
在文件 JobSystemThreadPool.cpp 第 584 行定义.
引用了 body.
◆ createTaskGroup()
|
overridevirtual |
Create a fork/join task group.
- 返回
- Heap-allocated TaskGroup; delete once joined.
在文件 JobSystemThreadPool.cpp 第 606 行定义.
◆ endFrame()
|
overridevirtual |
End the frame: join outstanding frame jobs and recycle the arena.
Blocks until every frame-scoped job finished, so results are safe to consume (e.g. before swapping GPU buffers). Idempotent with beginFrame().
在文件 JobSystemThreadPool.cpp 第 644 行定义.
◆ getOutstandingCount()
|
overridevirtual |
Number of scheduled jobs that have not finished (approximate).
在文件 JobSystemThreadPool.cpp 第 566 行定义.
◆ getPendingCount()
|
overridevirtual |
Number of ready jobs waiting for a worker (approximate).
在文件 JobSystemThreadPool.cpp 第 561 行定义.
◆ getWorkerCount()
|
overridevirtual |
Number of scheduler worker threads.
在文件 JobSystemThreadPool.cpp 第 552 行定义.
◆ isRunning()
|
overridevirtual |
Whether the system is still accepting new jobs.
在文件 JobSystemThreadPool.cpp 第 556 行定义.
◆ operator=()
|
delete |
◆ parallelFor()
|
overridevirtual |
Run body over [first, last) in parallel.
The range is statically split into ceil((last-first)/chunk) child jobs; the returned job represents the whole loop and finishes when every child is done. chunk <= 0 picks an automatic chunk targeting ~4 tasks per worker.
- 参数
-
first First index (inclusive). last One past the last index (exclusive). body Called on a worker for each subrange [first, last). chunk Subrange size per child task (default 1).
- 返回
- Heap-allocated loop Job; wait() on it joins the loop.
在文件 JobSystemThreadPool.cpp 第 602 行定义.
引用了 body.
◆ parallelForFrame()
|
overridevirtual |
Frame-scoped parallel_for; see parallelFor().
- 返回
- Arena-allocated loop Job; do not delete.
在文件 JobSystemThreadPool.cpp 第 628 行定义.
引用了 body.
◆ schedule()
|
overridevirtual |
Kick a paused job so it can run.
A job with no pending dependencies becomes ready immediately; a job with dependencies runs when its last predecessor finishes. Throws when the system is stopped or the job was already scheduled.
- 参数
-
job Job previously returned by createJob()/createFrameJob().
在文件 JobSystemThreadPool.cpp 第 589 行定义.
引用了 impl.
◆ stop()
|
overridevirtual |
Stop accepting work and join workers. Idempotent.
- 异常
-
eve::Exception when called from one of this system's workers.
在文件 JobSystemThreadPool.cpp 第 668 行定义.
◆ submit()
Create a job and schedule it immediately.
- 参数
-
body Work to run on a worker; may be empty to create a pure join/dependency node that just gates downstream jobs.
- 返回
- Heap-allocated Job; delete once finished.
在文件 JobSystemThreadPool.cpp 第 571 行定义.
引用了 body.
◆ submitFrame()
Create a frame-scoped job and schedule it immediately.
- 参数
-
body Work to run on a worker.
- 返回
- Arena-allocated Job; do not delete, valid until next beginFrame().
在文件 JobSystemThreadPool.cpp 第 610 行定义.
引用了 body.
◆ waitAll()
|
overridevirtual |
Block until every scheduled job has finished.
- 异常
-
eve::Exception when called from one of this system's workers.
在文件 JobSystemThreadPool.cpp 第 648 行定义.
引用了 state.
该类的文档由以下文件生成:
- src/modules/thread/JobSystemThreadPool.h
- src/modules/thread/JobSystemThreadPool.cpp
Public 成员函数 继承自