ThreadWeaver 5.109.0
|
DependencyPolicy implements execution-time dependencies dependencies between Jobs. More...
#include <dependencypolicy.h>
Public Member Functions | |
~DependencyPolicy () override | |
Destructor. | |
void | addDependency (const Dependency &dep) |
void | addDependency (JobPointer jobA, JobPointer jobB) |
Add jobB as a dependency of jobA. | |
bool | canRun (JobPointer) override |
canRun() is called before the job is executed. | |
void | destructed (JobInterface *job) override |
destructing() is called when a Job that has this queue policy assigned gets destructed. | |
void | free (JobPointer) override |
free() is called after the job has been executed. | |
bool | isEmpty () const |
void | release (JobPointer) override |
release() is called if canRun() returned true, but the job has not been executed for external reasons. | |
bool | removeDependency (const Dependency &dep) |
bool | removeDependency (JobPointer jobA, JobPointer jobB) |
Remove a dependency. | |
void | resolveDependencies (JobPointer) |
Resolve all dependencies for a job. | |
virtual bool | canRun (JobPointer)=0 |
canRun() is called before the job is executed. | |
virtual void | destructed (JobInterface *job)=0 |
destructing() is called when a Job that has this queue policy assigned gets destructed. | |
virtual void | free (JobPointer)=0 |
free() is called after the job has been executed. | |
virtual void | release (JobPointer)=0 |
release() is called if canRun() returned true, but the job has not been executed for external reasons. | |
Static Public Member Functions | |
static DependencyPolicy & | instance () |
Protected Member Functions | |
bool | hasUnresolvedDependencies (JobPointer) const |
Query whether the job has an unresolved dependency. | |
DependencyPolicy implements execution-time dependencies dependencies between Jobs.
To declare that Job B can only be executed when Job A is finished, call addDependency.
Be aware of circular dependencies. All dependencies on a Job will be removed if the Job object is destructed. Sequence uses dependencies to implement the ordered execution of the sequence elements.
|
override |
Destructor.
void ThreadWeaver::DependencyPolicy::addDependency | ( | JobPointer | jobA, |
JobPointer | jobB | ||
) |
Add jobB as a dependency of jobA.
jobA will only be executed after jobB has been successfully processed.
jobA | the depending job |
jobB | the job jobA depends on |
|
overridevirtual |
canRun() is called before the job is executed.
The job will only be executed if canRun() returns true.
Implements ThreadWeaver::QueuePolicy.
|
overridevirtual |
destructing() is called when a Job that has this queue policy assigned gets destructed.
Implements ThreadWeaver::QueuePolicy.
|
overridevirtual |
free() is called after the job has been executed.
It is guaranteed that free is called only after canRun() returned true at an earlier time.
Implements ThreadWeaver::QueuePolicy.
|
protected |
Query whether the job has an unresolved dependency.
In case it does, the policy will return false from canRun().
|
overridevirtual |
release() is called if canRun() returned true, but the job has not been executed for external reasons.
For example, a second QueuePolicy could have returned false from canRun() for the same job.
Implements ThreadWeaver::QueuePolicy.
bool ThreadWeaver::DependencyPolicy::removeDependency | ( | JobPointer | jobA, |
JobPointer | jobB | ||
) |
Remove a dependency.
The dependency of jobA on jobB is removed. If no dependencies are left for jobA, canRun will return true. Returns false if the given object is not dependency of this job.
jobA | the depending job |
jobB | the job jobA depends on |
void ThreadWeaver::DependencyPolicy::resolveDependencies | ( | JobPointer | ) |