AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agx::WaitJob Class Reference

A job used as a synchronization utility when waiting for another job to complete. More...

#include <Job.h>

+ Inheritance diagram for agx::WaitJob:

Public Types

typedef std::function< void()> CallbackFunction
 
using Delegate = agx::Delegate
 

Public Member Functions

 WaitJob (Job *job)
 
virtual ~WaitJob ()
 
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
 
Job * getTarget ()
 
const Job * getTarget () 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...
 
void release ()
 Release the waiting thread. More...
 
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...
 
void wait ()
 Blocks until the targeted job is completed. 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
 

Detailed Description

A job used as a synchronization utility when waiting for another job to complete.

Definition at line 364 of file Job.h.

Member Typedef Documentation

typedef std::function<void ()> agx::Callback::CallbackFunction
inherited

Definition at line 56 of file Callback.h.

using agx::Job::Delegate = agx::Delegate
inherited

Definition at line 62 of file Job.h.

Constructor & Destructor Documentation

agx::WaitJob::WaitJob ( Job *  job)
virtual agx::WaitJob::~WaitJob ( )
virtual

Member Function Documentation

void agx::Job::addDependency ( Job *  parent)
inherited

Add a dependency to a job.

Parameters
parentThe parent dependency

Definition at line 504 of file Job.h.

References agxAssert, agx::Job::m_children, agx::Job::m_numDependencies, agx::Job::m_parents, and agx::VectorPOD< T, Allocator >::push_back().

void agx::Job::clearChildDependencies ( )
inherited

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 agx::Job::m_children.

void agx::Job::decrementNumDependencies ( agx::UInt32  size = 1)
inherited

Explicitly decrement the number of parent dependencies.

Definition at line 549 of file Job.h.

References agx::Job::m_numDependencies.

Thread * agx::Job::getAssignedThread ( )
inherited
Returns
The thread which executed the job.

Definition at line 498 of file Job.h.

References agx::Job::m_assignedThread.

const Job::Delegate & agx::Job::getCallback ( ) const
inherited

Return the current callback.

Definition at line 554 of file Job.h.

References agx::Job::m_callback.

const JobPtrVector & agx::Job::getChildDependencies ( ) const
inherited
Returns
The list of child dependencies.

Definition at line 551 of file Job.h.

References agx::Job::m_children.

agx::UInt32 agx::Job::getCostEstimate ( ) const
inherited
Returns
The estimated job size.

Definition at line 576 of file Job.h.

References agx::Job::m_cost.

Referenced by agx::JobGroup::addJob().

Real agx::Job::getExecutionTime ( ) const
inherited
Returns
The execution time, in ms.

Definition at line 574 of file Job.h.

References agx::Timer::getTime(), and agx::Job::m_timer.

const char * agx::Job::getName ( ) const
inherited
Returns
The name of the job.

Definition at line 489 of file Job.h.

References agx::Job::m_name.

agx::UInt32 agx::Job::getNumDependencies ( ) const
inherited
Returns
The number of parent dependencies.

Definition at line 547 of file Job.h.

References agx::Job::m_numDependencies.

const JobPtrVector & agx::Job::getParentDependencies ( ) const
inherited
Returns
The parent jobs. NOTE Only available in debug build, in release the vector is always empty.

Definition at line 535 of file Job.h.

References agx::Job::m_parents.

SyncTag * agx::Job::getSyncTag ( )
inherited
Returns
The synchronization tag for this job.

Definition at line 496 of file Job.h.

References agx::Job::m_syncTag.

agx::UInt32 agx::Job::getTag ( ) const
inherited
Returns
The job tag.

Definition at line 500 of file Job.h.

References agx::Job::m_tag.

Job * agx::WaitJob::getTarget ( )
Returns
The target job to wait for.

Definition at line 697 of file Job.h.

const Job * agx::WaitJob::getTarget ( ) const

Definition at line 698 of file Job.h.

Thread * agx::Job::getTargetThread ( )
inherited
Returns
The thread this job is bound to. nullptr if no explicit thread binding.

Definition at line 492 of file Job.h.

References agx::Job::m_targetThread.

Task * agx::Job::getTask ( )
inherited
Returns
The task which this job is part of.

Definition at line 494 of file Job.h.

References agx::Job::m_task.

const Timer & agx::Job::getTimer ( ) const
inherited
Returns
The execution timer.

Definition at line 575 of file Job.h.

References agx::Job::m_timer.

bool agx::Job::hasDependency ( Job *  parent)
inherited
Parameters
parent- The parent job to check
Returns
True if the specified job is a direct parent dependency, not recursive.

Definition at line 529 of file Job.h.

References agxAssert, agx::VectorPOD< T, Allocator >::contains(), and agx::Job::m_children.

const Callback::CallbackFunction & agx::Callback::implementation ( ) const
inherited

Return the std representation.

Definition at line 271 of file Callback.h.

virtual void agx::Job::implementation ( )
virtualinherited

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)
inherited

Explicitly increment the number of parent dependencies.

Definition at line 548 of file Job.h.

References agx::Job::m_numDependencies.

agx::Index & agx::Job::index ( )
inherited
Returns
The index of the job (for parallel kernels)

Definition at line 579 of file Job.h.

References agx::Job::m_index.

const agx::Index & agx::Job::index ( ) const
inherited

Definition at line 580 of file Job.h.

References agx::Job::m_index.

bool agx::Callback::isRepeating ( ) const
inherited
Returns
True if the callback is repeating (when added to an agx::Event)

Definition at line 272 of file Callback.h.

Referenced by agx::Event::trigger().

bool agx::Callback::isValid ( ) const
inherited
Returns
True if the callback is non-void

Definition at line 283 of file Callback.h.

agx::Callback::operator bool ( ) const
inherited

Definition at line 284 of file Callback.h.

agx::Callback::operator const Callback::CallbackFunction & ( ) const
inherited

Definition at line 282 of file Callback.h.

void agx::Callback::operator() ( ) const
inherited

Execute the callback.

Definition at line 275 of file Callback.h.

References agx::Callback::run().

void agx::WaitJob::release ( )

Release the waiting thread.

Automatically called when the target job completes.

void agx::Job::removeAllDependencies ( )
inherited

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(), agx::Job::m_numDependencies, and agx::Job::m_parents.

void agx::Job::removeDependency ( Job *  parent)
inherited

Remove a dependency from a job.

Parameters
parentThe parent dependency

Definition at line 516 of file Job.h.

References agxAssert, agxVerify, agx::VectorPOD< T, Allocator >::findAndErase(), agx::Job::m_children, agx::Job::m_numDependencies, and agx::Job::m_parents.

bool agx::Job::resolve ( )
inherited

Increase the dependency counter for the job, and queue job for execution if all dependencies are resolved.

Automatically called as parent dependencies are completed.

Returns
true if all dependencies are resolved
void agx::Callback::run ( ) const
inherited

Definition at line 276 of file Callback.h.

References agxAssert.

Referenced by agx::Callback::operator()(), and agx::Event::trigger().

void agx::Job::setCallback ( const Delegate &  callback)
inherited

Set the callback which is called when execute() runs.

Definition at line 553 of file Job.h.

References agx::Job::m_callback.

void agx::Job::setCostEstimate ( agx::UInt32  cost)
inherited

Specify the cost estimate for this job.

Definition at line 577 of file Job.h.

References agx::Job::m_cost.

void agx::Job::setName ( const char *  name)
inherited

Set the name of the job, for debugging.

Definition at line 490 of file Job.h.

References agx::Job::m_name.

void agx::Job::setNumDependencies ( agx::UInt32  numDependencies)
inherited

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 agx::Job::m_numDependencies.

Referenced by agx::Job::init().

void agx::Job::setSyncTag ( SyncTag *  tag)
inherited

Set the synchronization tag which must enter completion status before the job is executed.

Definition at line 497 of file Job.h.

References agx::Job::m_syncTag.

void agx::Job::setTag ( agx::UInt32  tag)
inherited

Set the job tag, can be used to keep track of different job classes etc.

Definition at line 501 of file Job.h.

References agx::Job::m_tag.

void agx::Job::setTargetThread ( Thread *  thread)
inherited

Set the target thread which the job will be executed on.

Definition at line 493 of file Job.h.

References agx::Job::m_targetThread.

void agx::Job::setTask ( Task *  task)
inherited

Set the task which the job belongs to.

Normally handled automatically.

Definition at line 495 of file Job.h.

References agx::Job::m_task.

void agx::Job::spawn ( )
inherited

Schedule job for execution in thread pool.

void agx::WaitJob::wait ( )

Blocks until the targeted job is completed.

Member Data Documentation

Thread* agx::Job::m_assignedThread
protectedinherited

Definition at line 267 of file Job.h.

Referenced by agx::Job::getAssignedThread(), agx::Job::init(), and agx::Job::operator=().

Delegate agx::Job::m_callback
protectedinherited
std::atomic<Int32> agx::Job::m_dependencyCounter
protectedinherited

Definition at line 264 of file Job.h.

Referenced by agx::Job::operator=().

agx::Index agx::Job::m_index
protectedinherited

Definition at line 271 of file Job.h.

Referenced by agx::Job::index(), agx::Job::init(), and agx::Job::operator=().

const char* agx::Job::m_name
protectedinherited

Definition at line 258 of file Job.h.

Referenced by agx::Job::getName(), agx::Job::operator=(), and agx::Job::setName().

SyncTagRef agx::Job::m_syncTag
protectedinherited

Definition at line 268 of file Job.h.

Referenced by agx::Job::getSyncTag(), agx::Job::operator=(), and agx::Job::setSyncTag().

agx::UInt32 agx::Job::m_tag
protectedinherited

Definition at line 270 of file Job.h.

Referenced by agx::Job::getTag(), agx::Job::init(), agx::Job::operator=(), and agx::Job::setTag().

Thread* agx::Job::m_targetThread
protectedinherited
Task* agx::Job::m_task
protectedinherited

Definition at line 265 of file Job.h.

Referenced by agx::Job::getTask(), agx::Job::operator=(), and agx::Job::setTask().

Timer agx::Job::m_timer
protectedinherited

Definition at line 262 of file Job.h.

Referenced by agx::Job::getExecutionTime(), agx::Job::getTimer(), and agx::Job::operator=().


The documentation for this class was generated from the following file: