载入中...
搜索中...
未找到
JobSystem.h
浏览该文件的文档.
Abstract job scheduler: dependencies, parallel_for, task_group, arena.
Definition JobSystem.h:153
virtual Job * parallelForFrame(int first, int last, ParallelForBody body, int chunk=1)=0
Frame-scoped parallel_for; see parallelFor().
virtual Job * createJob(JobFunc body)=0
Create a paused job (dependencies can be wired, then schedule()).
virtual int getOutstandingCount() const =0
Number of scheduled jobs that have not finished (approximate).
virtual void beginFrame()=0
Start a new frame: join leftover frame jobs and recycle the arena.
virtual int getWorkerCount() const =0
Number of scheduler worker threads.
virtual Job * submit(JobFunc body)=0
Create a job and schedule it immediately.
virtual int getPendingCount() const =0
Number of ready jobs waiting for a worker (approximate).
virtual TaskGroup * createTaskGroup()=0
Create a fork/join task group.
virtual TaskGroup * createFrameTaskGroup()=0
Create a fork/join task group whose children are frame-scoped.
virtual ~JobSystem()=default
virtual void waitAll()=0
Block until every scheduled job has finished.
virtual Job * createFrameJob(JobFunc body)=0
Create a paused frame-scoped job.
virtual bool isRunning() const =0
Whether the system is still accepting new jobs.
virtual void endFrame()=0
End the frame: join outstanding frame jobs and recycle the arena.
virtual Job * parallelFor(int first, int last, ParallelForBody body, int chunk=1)=0
Run body over [first, last) in parallel.
virtual Job * submitFrame(JobFunc body)=0
Create a frame-scoped job and schedule it immediately.
virtual bool hasFailed() const =0
Whether the job body (or completion callback) failed.
virtual void addDependency(Job *predecessor)=0
Make this job wait for another job to finish first.
virtual int getPendingDependencyCount() const =0
Number of not-yet-completed predecessors this job is waiting for.
virtual void setCompletionCallback(JobFunc callback)=0
Register a callback fired once when the job finishes.
virtual ~Job()=default
virtual std::string getError() const =0
Error message from a failed body or completion callback.
virtual bool isDone() const =0
Whether the job has finished (done or failed).
Fork/join group: fork() spawns scheduled children, wait() joins them.
Definition JobSystem.h:106
virtual void wait()=0
Join every forked child: block until all of them finish. Safe from a worker thread.
virtual int getPendingCount() const =0
Number of forked children that have not finished yet.
virtual Job * fork(JobFunc body, JobFunc onComplete)=0
Spawn a scheduled child job with a completion callback.
virtual ~TaskGroup()=default
virtual Job * fork(JobFunc body)=0
Spawn a scheduled child job and add it to this group.
std::function< void(int first, int last)> ParallelForBody
Body of a parallel_for subrange.
Definition JobSystem.h:22
std::function< void()> JobFunc
A unit of work executed by a JobSystem worker.
Definition JobSystem.h:15
JobSystem * createJobSystem(int workerCount)
Create a JobSystem with the configured backend.
Definition JobSystem.cpp:14
Definition Build.cpp:11