22# pragma warning(disable:4355)
23# pragma warning(disable: 6011)
70 Job& operator=(
const Job& other);
79 void addDependency(
Job *parent);
85 void removeDependency(
Job *parent);
91 bool hasDependency(
Job *parent);
97 void removeAllDependencies();
103 void clearChildDependencies();
109 void setNumDependencies(
agx::UInt32 numDependencies);
119 void incrementNumDependencies(
agx::UInt32 size = 1);
124 void decrementNumDependencies(
agx::UInt32 size = 1);
139 void setCallback(
const Callback& callback);
144 const Callback& getCallback()
const;
161 Thread *getTargetThread();
166 void setTargetThread(
Thread *thread);
176 void setTask(
Task *task);
181 SyncTag *getSyncTag();
186 void setSyncTag(SyncTag *tag);
191 Real getExecutionTime()
const;
196 const Timer& getTimer()
const;
211 Thread *getAssignedThread();
227 void setName(
const char *name);
232 const char *getName()
const;
348 void addJob(
Job *job);
385 const Job *getTarget()
const;
423 m_numDependencies(0),
424 m_dependencyCounter(0),
426 m_targetThread(nullptr),
427 m_assignedThread(nullptr),
436 m_name(other.m_name),
437 m_children(other.m_children),
438 m_parents(other.m_parents),
439 m_callback(other.m_callback),
440 m_timer(other.m_timer),
441 m_numDependencies(other.m_numDependencies),
442 m_dependencyCounter(other.m_dependencyCounter.load()),
443 m_task(other.m_task),
444 m_targetThread(other.m_targetThread),
445 m_assignedThread(other.m_assignedThread),
446 m_syncTag(other.m_syncTag),
447 m_cost(other.m_cost),
449 m_index(other.m_index)
458 m_callback(callback),
459 m_numDependencies(0),
460 m_dependencyCounter(0),
462 m_targetThread(nullptr),
463 m_assignedThread(nullptr),
464 m_cost(costEstimate),
617 this->
init(callback,
range, costPerElement);
657 :
RangeJob(callback, range, costPerElement)
673 static_cast<T *
>(m_task)->dispatch(*
this);
#define AGX_TYPE_BINDING(_Type, _Name)
Block synchronization primitive.
Templated callback with one argument.
Generalized callback, using std::function.
A group of jobs to be executed.
const JobPtrVector & getSubJobs() const
virtual void implementation() override
Job implementation, override in subclass.
An abstract job/workblock representation, which allows work threads to execute arbitrary tasks.
void setTask(Task *task)
Set the task which the job belongs to.
void removeDependency(Job *parent)
Remove a dependency from a job.
agx::UInt32 getCostEstimate() const
bool hasDependency(Job *parent)
void setNumDependencies(agx::UInt32 numDependencies)
Explicitly set the number of parent dependencies.
Real getExecutionTime() const
void spawn()
Schedule job for execution in thread pool.
agx::UInt32 getNumDependencies() const
Thread * getTargetThread()
Job & operator=(const Job &other)
const Timer & getTimer() const
void addDependency(Job *parent)
Add a dependency to a job.
void setTargetThread(Thread *thread)
Set the target thread which the job will be executed on.
agx::UInt32 getTag() const
const JobPtrVector & getChildDependencies() const
void setTag(agx::UInt32 tag)
Set the job tag, can be used to keep track of different job classes etc.
void setCostEstimate(agx::UInt32 cost)
Specify the cost estimate for this job.
std::atomic< Int32 > m_dependencyCounter
void decrementNumDependencies(agx::UInt32 size=1)
Explicitly decrement the number of parent dependencies.
virtual void implementation()
Job implementation, override in subclass.
const char * getName() const
const Callback & getCallback() const
Return the current callback.
void init(const Callback &callback=Callback(), agx::UInt32 costEstimate=100)
Initialize the job.
void incrementNumDependencies(agx::UInt32 size=1)
Explicitly increment the number of parent dependencies.
void clearChildDependencies()
Remove all child dependencies.
void removeAllDependencies()
Remove all parent dependencies.
Thread * m_assignedThread
void setName(const char *name)
Set the name of the job, for debugging.
bool resolve()
Increase the dependency counter for the job, and queue job for execution if all dependencies are reso...
void setSyncTag(SyncTag *tag)
Set the synchronization tag which must enter completion status before the job is executed.
const JobPtrVector & getParentDependencies() const
void setCallback(const Callback &callback)
Set the callback which is called when execute() runs.
Thread * getAssignedThread()
agx::UInt32 m_numDependencies
virtual void implementation() override
Job implementation, override in subclass.
A range job executes a kernel implementation on a subset of the data.
void init(const RangeCallback &callback, const IndexRange &range, agx::UInt32 costPerElement=1)
virtual void implementation() override
Job implementation, override in subclass.
RangeCallback m_rangeCallback
RangeJob & operator=(const RangeJob &other)
A task job is a job which executes an agx::Task.
A representation of a generic task.
agx::Thread is a representation of an OS specific implementation of a computational thread.
The Timer class permits timing execution speed with the same refinement as the built in hardware cloc...
Real64 getTime() const
Report total elapsed time since start in milliseconds, excluding intervals when the timer was suspend...
Vector containing 'raw' data.
void push_back(const T &value)
bool contains(const T2 &element) const
Test if the vector contains a certain element.
bool findAndErase(const T &element, bool searchMultiple=false)
Find and erase an element.
void clear(ClearPolicy policy=SHRINK_BUFFER_AVERAGED)
Remove all elements, optionally with maintained buffer allocation.
A job used as a synchronization utility when waiting for another job to complete.
void release()
Release the waiting thread.
void wait()
Blocks until the targeted job is completed.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Vector< RangeJob > RangeJobVector
VectorPOD< class Job * > JobPtrVector
std::deque< class Job * > JobPtrQueue
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
agx::Callback1< const RangeJob & > RangeCallback
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API.