Handle to a single job inside a JobSystem. 更多...
#include <JobSystem.h>
Public 成员函数 | |
| virtual | ~Job ()=default |
| virtual void | wait ()=0 |
| Block until this job finishes (done or failed). | |
| virtual bool | isDone () const =0 |
| Whether the job has finished (done or failed). | |
| virtual bool | hasFailed () const =0 |
| Whether the job body (or completion callback) failed. | |
| virtual std::string | getError () const =0 |
| Error message from a failed body or completion callback. | |
| virtual int | getPendingDependencyCount () const =0 |
| Number of not-yet-completed predecessors this job is waiting for. | |
| virtual void | addDependency (Job *predecessor)=0 |
| Make this job wait for another job to finish first. | |
| virtual void | setCompletionCallback (JobFunc callback)=0 |
| Register a callback fired once when the job finishes. | |
详细描述
Handle to a single job inside a JobSystem.
Every job carries a dependency count and an optional completion callback so a render graph can be wired on top without rewriting the scheduler: createJob() gives a paused job, addDependency() increments its dependency count, schedule() kicks it, and setCompletionCallback() registers a callback that fires on the finishing worker.
Heap jobs are owned by the caller: delete them once they have finished (isDone() or after wait()). Frame jobs are owned by the JobSystem arena and must never be deleted; they stay valid until the next beginFrame()/endFrame().
Thread-safety: a job may be waited on or deleted from any thread, and dependencies may be added from any thread, but a job must be fully wired (all addDependency calls) before it is scheduled.
在文件 JobSystem.h 第 41 行定义.
构造及析构函数说明
◆ ~Job()
|
virtualdefault |
成员函数说明
◆ addDependency()
|
pure virtual |
◆ getError()
|
pure virtual |
Error message from a failed body or completion callback.
- 返回
- Empty string when the job did not fail.
◆ getPendingDependencyCount()
|
pure virtual |
Number of not-yet-completed predecessors this job is waiting for.
- 返回
- Dependency count; 0 means the job is runnable once scheduled.
◆ hasFailed()
|
pure virtual |
Whether the job body (or completion callback) failed.
◆ isDone()
|
pure virtual |
Whether the job has finished (done or failed).
◆ setCompletionCallback()
|
pure virtual |
Register a callback fired once when the job finishes.
Runs on the worker that executed the job, before any dependent job is released, so it is safe for the callback to publish results that downstream jobs consume. Exceptions thrown by the callback are caught and recorded (hasFailed() stays false for the body's sake; getError() reports the callback failure). If the job already finished, the callback runs immediately on the calling thread.
- 参数
-
callback Callable invoked on completion (may be empty to clear).
◆ wait()
|
pure virtual |
Block until this job finishes (done or failed).
Safe to call from a JobSystem worker: the calling worker helps execute ready jobs while it waits (fork/join pattern). Throws if a job waits on itself.
该类的文档由以下文件生成:
- src/modules/thread/JobSystem.h