About
A job is a threaded, reusable, independent work item (task). It can be queued to be executed with other jobs in a (parallel) pipeline.
Job
A custom job is based on maxon::JobInterfaceTemplate, maxon::JobResultInterface and maxon::JobInterface. The custom class contains data and implements the function call operator with the actual workload. A job instance is based on maxon::JobRef.
- Warning
- Make sure that a job has no additional, hidden dependencies like for example executing parallelized code internally.
{
public:
FactorialJob() { };
{
}
{
{
factorial = _n;
while (_n > 1)
{
--_n;
factorial *= _n;
}
}
}
private:
};
const Py_UNICODE size_t n
Definition: unicodeobject.h:1184
#define MAXON_IMPLICIT
Definition: apibase.h:172
UInt64 UInt
unsigned 32/64 bit int, size depends on the platform
Definition: apibase.h:189
#define MAXON_LIKELY(X)
Definition: compilerdetection.h:403
ResultOk< void > SetResult()
Definition: job.h:1059
A job can also implement:
A job has to be enqueued in a queue to be executed (see job queue below):
job.Enqueue();
static auto Create(ARGS &&... args)
Definition: apibase.h:2750
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
#define iferr_return
Definition: resultbase.h:1465
A running job can be cancelled:
These observers can be used to react to certain events:
Further utility function are:
Static utility functions are:
Job Group
Jobs can be organized in job groups. These groups are used to execute and wait for multiple jobs simultaneously. The jobs of a group typically belong together. The jobs are executed as efficiently as possible.
The maxon::JobGroupRef members are:
{
{
}
Reference to a group (JobGroupInterface).
Definition: jobgroup.h:403
Result< void > Add(T &&obj)
Definition: jobgroup.h:523
Bool Wait(TimeValue timeout=TIMEVALUE_INFINITE, WAITMODE mode=WAITMODE::DEFAULT) const
Definition: jobgroup.h:474
JobGroupRef & Enqueue(JobQueueInterface *queue=JOBQUEUE_CURRENT)
Definition: jobgroup.h:427
static ResultMemT< JobGroupRef > Create(JOBGROUPFLAGS flags=JOBGROUPFLAGS::DEFAULT)
Definition: jobgroup.h:414
for(i=0;i< length;i++)
Definition: unicodeobject.h:61
The maxon namespace contains all declarations of the MAXON API.
Definition: autoweight.h:14
#define iferr_ignore(...)
Definition: resultbase.h:1430
const char const char const char * file
Definition: object.h:439
{
{
return CreateFileHash(
file);
}
Reference to a job (JobInterface).
Definition: job.h:1222
static auto Create(FN &&src, ARGS &&... args) -> ResultMemT< JobResultRef< decltype(src(std::forward< ARGS >(args)...))>>
Definition: job.h:1245
maxon::BaseArray<FileHashJob> jobs;
{
}
Int GetCount(const ITERABLE &iterable)
Definition: collection.h:37
Jobs that do belong to a job group can handle sub-jobs:
Queue
Jobs are added to a queue which executes these jobs. A queue provides worker threads and distributes the jobs.
- Note
- Typically it is not needed to create a custom queue. maxon::JOBQUEUE_CURRENT should be used.
Default job queues are:
It is possible to manually create queues in order to organize job execution.
- Note
- Functions like maxon::JobInterface::Enqueue() or maxon::JobGroupRef::Enqueue() add the job or jobs to the current job queue if no argument is given.
Further Reading