ThreadWeaver::DependencyPolicy
#include <dependencypolicy.h>
Public Member Functions | |
~DependencyPolicy () override | |
void | addDependency (const Dependency &dep) |
void | addDependency (JobPointer jobA, JobPointer jobB) |
bool | canRun (JobPointer) override |
void | destructed (JobInterface *job) override |
void | free (JobPointer) override |
bool | isEmpty () const |
void | release (JobPointer) override |
bool | removeDependency (const Dependency &dep) |
bool | removeDependency (JobPointer jobA, JobPointer jobB) |
void | resolveDependencies (JobPointer) |
Public Member Functions inherited from ThreadWeaver::QueuePolicy |
Static Public Member Functions | |
static DependencyPolicy & | instance () |
Protected Member Functions | |
bool | hasUnresolvedDependencies (JobPointer) const |
Detailed Description
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.
Definition at line 32 of file dependencypolicy.h.
Constructor & Destructor Documentation
◆ ~DependencyPolicy()
|
override |
Destructor.
Definition at line 54 of file dependencypolicy.cpp.
Member Function Documentation
◆ addDependency() [1/2]
void DependencyPolicy::addDependency | ( | const Dependency & | dep | ) |
Definition at line 74 of file dependencypolicy.cpp.
◆ addDependency() [2/2]
void DependencyPolicy::addDependency | ( | JobPointer | jobA, |
JobPointer | jobB ) |
Add jobB as a dependency of jobA.
jobA will only be executed after jobB has been successfully processed.
- Parameters
-
jobA the depending job jobB the job jobA depends on
Definition at line 59 of file dependencypolicy.cpp.
◆ canRun()
|
overridevirtual |
canRun() is called before the job is executed.
The job will only be executed if canRun() returns true.
Implements ThreadWeaver::QueuePolicy.
Definition at line 158 of file dependencypolicy.cpp.
◆ destructed()
|
overridevirtual |
destructing() is called when a Job that has this queue policy assigned gets destructed.
Implements ThreadWeaver::QueuePolicy.
Definition at line 183 of file dependencypolicy.cpp.
◆ free()
|
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.
Definition at line 164 of file dependencypolicy.cpp.
◆ hasUnresolvedDependencies()
|
protected |
Query whether the job has an unresolved dependency.
In case it does, the policy will return false from canRun().
Definition at line 139 of file dependencypolicy.cpp.
◆ instance()
|
static |
Retrieve a list of dependencies of this job.
Definition at line 152 of file dependencypolicy.cpp.
◆ isEmpty()
bool DependencyPolicy::isEmpty | ( | ) | const |
Definition at line 146 of file dependencypolicy.cpp.
◆ release()
|
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.
Definition at line 177 of file dependencypolicy.cpp.
◆ removeDependency() [1/2]
bool DependencyPolicy::removeDependency | ( | const Dependency & | dep | ) |
Definition at line 101 of file dependencypolicy.cpp.
◆ removeDependency() [2/2]
bool 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.
- Parameters
-
jobA the depending job jobB the job jobA depends on
- Returns
- true if dependency existed, false otherwise
Definition at line 79 of file dependencypolicy.cpp.
◆ resolveDependencies()
void DependencyPolicy::resolveDependencies | ( | JobPointer | job | ) |
Resolve all dependencies for a job.
This method is called after the Job has been finished, or when it is deleted without being executed (performed by the destructor). The method will remove all entries stating that another Job depends on this one.
Definition at line 106 of file dependencypolicy.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 13 2024 11:49:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.