|
AGXDynamics
2.31.1.0
|
An abstract job/workblock representation, which allows work threads to execute arbitrary tasks. More...
#include <Job.h>
Inheritance diagram for agx::Job:Public Types | |
| typedef std::function< void()> | CallbackFunction |
| using | Delegate = agx::Delegate |
Public Member Functions | |
| Job () | |
| Job (const Job &other) | |
| Job (const Delegate &callback, agx::UInt32 costEstimate=100) | |
| virtual | ~Job () |
| void | addDependency (Job *parent) |
| Add a dependency to a job. More... | |
| void | clearChildDependencies () |
| Remove all child dependencies. More... | |
| void | decrementNumDependencies (agx::UInt32 size=1) |
| Explicitly decrement the number of parent dependencies. More... | |
| Thread * | getAssignedThread () |
| const Delegate & | getCallback () const |
| Return the current callback. More... | |
| const JobPtrVector & | getChildDependencies () const |
| agx::UInt32 | getCostEstimate () const |
| Real | getExecutionTime () const |
| const char * | getName () const |
| agx::UInt32 | getNumDependencies () const |
| const JobPtrVector & | getParentDependencies () const |
| SyncTag * | getSyncTag () |
| agx::UInt32 | getTag () const |
| Thread * | getTargetThread () |
| Task * | getTask () |
| const Timer & | getTimer () const |
| bool | hasDependency (Job *parent) |
| const CallbackFunction & | implementation () const |
| Return the std representation. More... | |
| virtual void | implementation () |
| Job implementation, override in subclass. More... | |
| void | incrementNumDependencies (agx::UInt32 size=1) |
| Explicitly increment the number of parent dependencies. More... | |
| agx::Index & | index () |
| const agx::Index & | index () const |
| void | init (const Delegate &callback=Delegate(), agx::UInt32 costEstimate=100) |
| Initialize the job. More... | |
| bool | isRepeating () const |
| bool | isValid () const |
| operator bool () const | |
| operator const CallbackFunction & () const | |
| void | operator() () const |
| Execute the callback. More... | |
| Job & | operator= (const Job &other) |
| void | removeAllDependencies () |
| Remove all parent dependencies. More... | |
| void | removeDependency (Job *parent) |
| Remove a dependency from a job. More... | |
| bool | resolve () |
| Increase the dependency counter for the job, and queue job for execution if all dependencies are resolved. More... | |
| void | run () const |
| void | setCallback (const Delegate &callback) |
| Set the callback which is called when execute() runs. More... | |
| void | setCostEstimate (agx::UInt32 cost) |
| Specify the cost estimate for this job. More... | |
| void | setName (const char *name) |
| Set the name of the job, for debugging. More... | |
| void | setNumDependencies (agx::UInt32 numDependencies) |
| Explicitly set the number of parent dependencies. More... | |
| void | setSyncTag (SyncTag *tag) |
| Set the synchronization tag which must enter completion status before the job is executed. More... | |
| void | setTag (agx::UInt32 tag) |
| Set the job tag, can be used to keep track of different job classes etc. More... | |
| void | setTargetThread (Thread *thread) |
| Set the target thread which the job will be executed on. More... | |
| void | setTask (Task *task) |
| Set the task which the job belongs to. More... | |
| void | spawn () |
| Schedule job for execution in thread pool. More... | |
Protected Attributes | |
| Thread * | m_assignedThread |
| Delegate | m_callback |
| JobPtrVector | m_children |
| agx::UInt32 | m_cost |
| std::atomic< Int32 > | m_dependencyCounter |
| agx::Index | m_index |
| const char * | m_name |
| agx::UInt32 | m_numDependencies |
| JobPtrVector | m_parents |
| SyncTagRef | m_syncTag |
| agx::UInt32 | m_tag |
| Thread * | m_targetThread |
| Task * | m_task |
| Timer | m_timer |
An abstract job/workblock representation, which allows work threads to execute arbitrary tasks.
The jobs have specified dependecies which enables them to be organized in an execution graph.
|
inherited |
Definition at line 56 of file Callback.h.
| using agx::Job::Delegate = agx::Delegate |
| agx::Job::Job | ( | const Delegate & | callback, |
| agx::UInt32 | costEstimate = 100 |
||
| ) |
|
virtual |
Add a dependency to a job.
| parent | The parent dependency |
Definition at line 504 of file Job.h.
References agxAssert, m_children, m_numDependencies, m_parents, and agx::VectorPOD< T, Allocator >::push_back().
| void agx::Job::clearChildDependencies | ( | ) |
Remove all child dependencies.
NOTE: Parent dependencies in children are not updated
Definition at line 537 of file Job.h.
References agx::VectorPOD< T, Allocator >::clear(), and m_children.
| void agx::Job::decrementNumDependencies | ( | agx::UInt32 | size = 1 | ) |
Explicitly decrement the number of parent dependencies.
Definition at line 549 of file Job.h.
References m_numDependencies.
| Thread * agx::Job::getAssignedThread | ( | ) |
Definition at line 498 of file Job.h.
References m_assignedThread.
| const Job::Delegate & agx::Job::getCallback | ( | ) | const |
| const JobPtrVector & agx::Job::getChildDependencies | ( | ) | const |
| agx::UInt32 agx::Job::getCostEstimate | ( | ) | const |
Definition at line 576 of file Job.h.
References m_cost.
Referenced by agx::JobGroup::addJob().
| Real agx::Job::getExecutionTime | ( | ) | const |
Definition at line 574 of file Job.h.
References agx::Timer::getTime(), and m_timer.
| const char * agx::Job::getName | ( | ) | const |
| agx::UInt32 agx::Job::getNumDependencies | ( | ) | const |
Definition at line 547 of file Job.h.
References m_numDependencies.
| const JobPtrVector & agx::Job::getParentDependencies | ( | ) | const |
| SyncTag * agx::Job::getSyncTag | ( | ) |
| agx::UInt32 agx::Job::getTag | ( | ) | const |
| Thread * agx::Job::getTargetThread | ( | ) |
Definition at line 492 of file Job.h.
References m_targetThread.
| Task * agx::Job::getTask | ( | ) |
| const Timer & agx::Job::getTimer | ( | ) | const |
| bool agx::Job::hasDependency | ( | Job * | parent | ) |
| parent | - The parent job to check |
Definition at line 529 of file Job.h.
References agxAssert, agx::VectorPOD< T, Allocator >::contains(), and m_children.
|
inherited |
Return the std representation.
Definition at line 271 of file Callback.h.
|
virtual |
Job implementation, override in subclass.
Default implementation use a generic callback.
Reimplemented in agx::JobGroup, agx::RangeJobT< T >, and agx::RangeJob.
| void agx::Job::incrementNumDependencies | ( | agx::UInt32 | size = 1 | ) |
Explicitly increment the number of parent dependencies.
Definition at line 548 of file Job.h.
References m_numDependencies.
| agx::Index & agx::Job::index | ( | ) |
| const agx::Index & agx::Job::index | ( | ) | const |
| void agx::Job::init | ( | const Delegate & | callback = Delegate(), |
| agx::UInt32 | costEstimate = 100 |
||
| ) |
Initialize the job.
Definition at line 557 of file Job.h.
References agx::VectorPOD< T, Allocator >::clear(), m_assignedThread, m_callback, m_children, m_cost, m_index, m_parents, m_tag, m_targetThread, and setNumDependencies().
Referenced by agx::RangeJob::init(), agx::JobGroup::init(), and agx::TaskJob::init().
|
inherited |
Definition at line 272 of file Callback.h.
Referenced by agx::Event::trigger().
|
inherited |
Definition at line 283 of file Callback.h.
|
inherited |
Definition at line 284 of file Callback.h.
|
inherited |
Definition at line 282 of file Callback.h.
|
inherited |
Definition at line 469 of file Job.h.
References m_assignedThread, m_callback, m_children, m_cost, m_dependencyCounter, m_index, m_name, m_numDependencies, m_parents, m_syncTag, m_tag, m_targetThread, m_task, and m_timer.
| void agx::Job::removeAllDependencies | ( | ) |
Remove all parent dependencies.
NOTE: Child dependencies in parents are not updated
Definition at line 539 of file Job.h.
References agx::VectorPOD< T, Allocator >::clear(), m_numDependencies, and m_parents.
Remove a dependency from a job.
| parent | The parent dependency |
Definition at line 516 of file Job.h.
References agxAssert, agxVerify, agx::VectorPOD< T, Allocator >::findAndErase(), m_children, m_numDependencies, and m_parents.
| bool agx::Job::resolve | ( | ) |
Increase the dependency counter for the job, and queue job for execution if all dependencies are resolved.
Automatically called as parent dependencies are completed.
|
inherited |
Definition at line 276 of file Callback.h.
References agxAssert.
Referenced by agx::Callback::operator()(), and agx::Event::trigger().
Set the callback which is called when execute() runs.
Definition at line 553 of file Job.h.
References m_callback.
| void agx::Job::setCostEstimate | ( | agx::UInt32 | cost | ) |
| void agx::Job::setName | ( | const char * | name | ) |
| void agx::Job::setNumDependencies | ( | agx::UInt32 | numDependencies | ) |
Explicitly set the number of parent dependencies.
NOTE: Only use if you know what you are doing....
Definition at line 538 of file Job.h.
References m_numDependencies.
Referenced by init().
| void agx::Job::setSyncTag | ( | SyncTag * | tag | ) |
| void agx::Job::setTag | ( | agx::UInt32 | tag | ) |
Set the target thread which the job will be executed on.
Definition at line 493 of file Job.h.
References m_targetThread.
| void agx::Job::spawn | ( | ) |
Schedule job for execution in thread pool.
|
protected |
Definition at line 267 of file Job.h.
Referenced by getAssignedThread(), init(), and operator=().
|
protected |
Definition at line 261 of file Job.h.
Referenced by getCallback(), init(), operator=(), and setCallback().
|
protected |
Definition at line 259 of file Job.h.
Referenced by addDependency(), clearChildDependencies(), getChildDependencies(), hasDependency(), init(), operator=(), and removeDependency().
|
protected |
Definition at line 269 of file Job.h.
Referenced by agx::JobGroup::addJob(), getCostEstimate(), init(), agx::JobGroup::init(), operator=(), and setCostEstimate().
|
protected |
Definition at line 264 of file Job.h.
Referenced by operator=().
|
protected |
Definition at line 271 of file Job.h.
Referenced by index(), init(), and operator=().
|
protected |
Definition at line 258 of file Job.h.
Referenced by getName(), operator=(), and setName().
|
protected |
Definition at line 263 of file Job.h.
Referenced by addDependency(), decrementNumDependencies(), getNumDependencies(), incrementNumDependencies(), operator=(), removeAllDependencies(), removeDependency(), and setNumDependencies().
|
protected |
Definition at line 260 of file Job.h.
Referenced by addDependency(), getParentDependencies(), init(), operator=(), removeAllDependencies(), and removeDependency().
|
protected |
Definition at line 268 of file Job.h.
Referenced by getSyncTag(), operator=(), and setSyncTag().
|
protected |
|
protected |
Definition at line 266 of file Job.h.
Referenced by getTargetThread(), init(), operator=(), and setTargetThread().
|
protected |
Definition at line 265 of file Job.h.
Referenced by getTask(), operator=(), and setTask().
|
protected |
Definition at line 262 of file Job.h.
Referenced by getExecutionTime(), getTimer(), and operator=().