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

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.h41 行定义.

构造及析构函数说明

◆ ~Job()

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

成员函数说明

◆ addDependency()

virtual void eve::thread::Job::addDependency ( Job predecessor)
pure virtual

Make this job wait for another job to finish first.

Must be called before schedule(); throws otherwise. A dependency on an already-finished job is ignored. Both jobs must belong to the same JobSystem.

参数
predecessorJob that must complete before this one runs.

◆ getError()

virtual std::string eve::thread::Job::getError ( ) const
pure virtual

Error message from a failed body or completion callback.

返回
Empty string when the job did not fail.

◆ getPendingDependencyCount()

virtual int eve::thread::Job::getPendingDependencyCount ( ) const
pure virtual

Number of not-yet-completed predecessors this job is waiting for.

返回
Dependency count; 0 means the job is runnable once scheduled.

◆ hasFailed()

virtual bool eve::thread::Job::hasFailed ( ) const
pure virtual

Whether the job body (or completion callback) failed.

◆ isDone()

virtual bool eve::thread::Job::isDone ( ) const
pure virtual

Whether the job has finished (done or failed).

◆ setCompletionCallback()

virtual void eve::thread::Job::setCompletionCallback ( JobFunc  callback)
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.

参数
callbackCallable invoked on completion (may be empty to clear).

◆ wait()

virtual void eve::thread::Job::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.

被这些函数引用 eve::voxel::VoxelWorld::remeshDirty().


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