载入中...
搜索中...
未找到
eve::thread::JobSystem类 参考abstract

Abstract job scheduler: dependencies, parallel_for, task_group, arena. 更多...

#include <JobSystem.h>

类 eve::thread::JobSystem 继承关系图:
eve::thread::JobSystemThreadPool

Public 成员函数

virtual ~JobSystem ()=default
 
virtual int getWorkerCount () const =0
 Number of scheduler worker threads.
 
virtual bool isRunning () const =0
 Whether the system is still accepting new jobs.
 
virtual int getPendingCount () const =0
 Number of ready jobs waiting for a worker (approximate).
 
virtual int getOutstandingCount () const =0
 Number of scheduled jobs that have not finished (approximate).
 
virtual Jobsubmit (JobFunc body)=0
 Create a job and schedule it immediately.
 
virtual JobcreateJob (JobFunc body)=0
 Create a paused job (dependencies can be wired, then schedule()).
 
virtual void schedule (Job *job)=0
 Kick a paused job so it can run.
 
virtual JobparallelFor (int first, int last, ParallelForBody body, int chunk=1)=0
 Run body over [first, last) in parallel.
 
virtual TaskGroupcreateTaskGroup ()=0
 Create a fork/join task group.
 
virtual JobsubmitFrame (JobFunc body)=0
 Create a frame-scoped job and schedule it immediately.
 
virtual JobcreateFrameJob (JobFunc body)=0
 Create a paused frame-scoped job.
 
virtual JobparallelForFrame (int first, int last, ParallelForBody body, int chunk=1)=0
 Frame-scoped parallel_for; see parallelFor().
 
virtual TaskGroupcreateFrameTaskGroup ()=0
 Create a fork/join task group whose children are frame-scoped.
 
virtual void beginFrame ()=0
 Start a new frame: join leftover frame jobs and recycle the arena.
 
virtual void endFrame ()=0
 End the frame: join outstanding frame jobs and recycle the arena.
 
virtual void waitAll ()=0
 Block until every scheduled job has finished.
 
virtual void stop ()=0
 Stop accepting work and join workers. Idempotent.
 

详细描述

Abstract job scheduler: dependencies, parallel_for, task_group, arena.

This is the stable engine-wide API for CPU job scheduling. The default backend (JobSystemThreadPool) schedules on top of the existing ThreadPool worker pool; a TBB backend only needs to implement this interface, and the factory in JobSystem.cpp is the single file that chooses the backend.

Two allocation scopes exist:

  • Heap jobs (submit/createJob/parallelFor/createTaskGroup): caller-owned handles, deleted with delete once finished. Long-lived work (async scene loading) belongs here.
  • Frame jobs (submitFrame/createFrameJob/parallelForFrame/ createFrameTaskGroup): allocated from a per-frame arena that is recycled by beginFrame()/endFrame(), so per-frame job submission does no new/delete. Handles are valid until the next beginFrame()/endFrame() and must not be deleted.

在文件 JobSystem.h153 行定义.

构造及析构函数说明

◆ ~JobSystem()

virtual eve::thread::JobSystem::~JobSystem ( )
virtualdefault

成员函数说明

◆ beginFrame()

virtual void eve::thread::JobSystem::beginFrame ( )
pure virtual

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.

eve::thread::JobSystemThreadPool 内被实现.

◆ createFrameJob()

virtual Job * eve::thread::JobSystem::createFrameJob ( JobFunc  body)
pure virtual

Create a paused frame-scoped job.

参数
bodyWork to run on a worker.
返回
Arena-allocated Job; do not delete, valid until next beginFrame().

eve::thread::JobSystemThreadPool 内被实现.

◆ createFrameTaskGroup()

virtual TaskGroup * eve::thread::JobSystem::createFrameTaskGroup ( )
pure virtual

Create a fork/join task group whose children are frame-scoped.

返回
Arena-allocated TaskGroup; do not delete, valid until next beginFrame().

eve::thread::JobSystemThreadPool 内被实现.

被这些函数引用 eve::graphics::vulkan::jobSystemPassExecutor().

◆ createJob()

virtual Job * eve::thread::JobSystem::createJob ( JobFunc  body)
pure virtual

Create a paused job (dependencies can be wired, then schedule()).

参数
bodyWork 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.

eve::thread::JobSystemThreadPool 内被实现.

◆ createTaskGroup()

virtual TaskGroup * eve::thread::JobSystem::createTaskGroup ( )
pure virtual

Create a fork/join task group.

返回
Heap-allocated TaskGroup; delete once joined.

eve::thread::JobSystemThreadPool 内被实现.

◆ endFrame()

virtual void eve::thread::JobSystem::endFrame ( )
pure virtual

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().

eve::thread::JobSystemThreadPool 内被实现.

◆ getOutstandingCount()

virtual int eve::thread::JobSystem::getOutstandingCount ( ) const
pure virtual

Number of scheduled jobs that have not finished (approximate).

eve::thread::JobSystemThreadPool 内被实现.

◆ getPendingCount()

virtual int eve::thread::JobSystem::getPendingCount ( ) const
pure virtual

Number of ready jobs waiting for a worker (approximate).

eve::thread::JobSystemThreadPool 内被实现.

◆ getWorkerCount()

virtual int eve::thread::JobSystem::getWorkerCount ( ) const
pure virtual

Number of scheduler worker threads.

eve::thread::JobSystemThreadPool 内被实现.

◆ isRunning()

virtual bool eve::thread::JobSystem::isRunning ( ) const
pure virtual

Whether the system is still accepting new jobs.

eve::thread::JobSystemThreadPool 内被实现.

◆ parallelFor()

virtual Job * eve::thread::JobSystem::parallelFor ( int  first,
int  last,
ParallelForBody  body,
int  chunk = 1 
)
pure virtual

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.

参数
firstFirst index (inclusive).
lastOne past the last index (exclusive).
bodyCalled on a worker for each subrange [first, last).
chunkSubrange size per child task (default 1).
返回
Heap-allocated loop Job; wait() on it joins the loop.

eve::thread::JobSystemThreadPool 内被实现.

◆ parallelForFrame()

virtual Job * eve::thread::JobSystem::parallelForFrame ( int  first,
int  last,
ParallelForBody  body,
int  chunk = 1 
)
pure virtual

Frame-scoped parallel_for; see parallelFor().

返回
Arena-allocated loop Job; do not delete.

eve::thread::JobSystemThreadPool 内被实现.

◆ schedule()

virtual void eve::thread::JobSystem::schedule ( Job job)
pure virtual

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.

参数
jobJob previously returned by createJob()/createFrameJob().

eve::thread::JobSystemThreadPool 内被实现.

◆ stop()

virtual void eve::thread::JobSystem::stop ( )
pure virtual

Stop accepting work and join workers. Idempotent.

异常
eve::Exceptionwhen called from one of this system's workers.

eve::thread::JobSystemThreadPool 内被实现.

◆ submit()

virtual Job * eve::thread::JobSystem::submit ( JobFunc  body)
pure virtual

Create a job and schedule it immediately.

参数
bodyWork 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.

eve::thread::JobSystemThreadPool 内被实现.

◆ submitFrame()

virtual Job * eve::thread::JobSystem::submitFrame ( JobFunc  body)
pure virtual

Create a frame-scoped job and schedule it immediately.

参数
bodyWork to run on a worker.
返回
Arena-allocated Job; do not delete, valid until next beginFrame().

eve::thread::JobSystemThreadPool 内被实现.

◆ waitAll()

virtual void eve::thread::JobSystem::waitAll ( )
pure virtual

Block until every scheduled job has finished.

异常
eve::Exceptionwhen called from one of this system's workers.

eve::thread::JobSystemThreadPool 内被实现.


该类的文档由以下文件生成: