22# pragma warning(disable:4355)
23# pragma warning(disable: 6011)
68 Job& operator=(
const Job& other);
77 void addDependency(
Job *parent);
83 void removeDependency(
Job *parent);
89 bool hasDependency(
Job *parent);
95 void removeAllDependencies();
101 void clearChildDependencies();
107 void setNumDependencies(
agx::UInt32 numDependencies);
117 void incrementNumDependencies(
agx::UInt32 size = 1);
122 void decrementNumDependencies(
agx::UInt32 size = 1);
137 void setCallback(
const Callback& callback);
142 const Callback& getCallback()
const;
159 Thread *getTargetThread();
164 void setTargetThread(
Thread *thread);
174 void setTask(
Task *task);
179 SyncTag *getSyncTag();
184 void setSyncTag(SyncTag *tag);
189 Real getExecutionTime()
const;
194 const Timer& getTimer()
const;
209 Thread *getAssignedThread();
225 void setName(
const char *name);
230 const char *getName()
const;
346 void addJob(
Job *job);
383 const Job *getTarget()
const;
421 m_numDependencies(0),
422 m_dependencyCounter(0),
424 m_targetThread(nullptr),
425 m_assignedThread(nullptr),
434 m_name(other.m_name),
435 m_children(other.m_children),
436 m_parents(other.m_parents),
437 m_callback(other.m_callback),
438 m_timer(other.m_timer),
439 m_numDependencies(other.m_numDependencies),
440 m_dependencyCounter(other.m_dependencyCounter.load()),
441 m_task(other.m_task),
442 m_targetThread(other.m_targetThread),
443 m_assignedThread(other.m_assignedThread),
444 m_syncTag(other.m_syncTag),
445 m_cost(other.m_cost),
447 m_index(other.m_index)
456 m_callback(callback),
457 m_numDependencies(0),
458 m_dependencyCounter(0),
460 m_targetThread(nullptr),
461 m_assignedThread(nullptr),
462 m_cost(costEstimate),
615 this->
init(callback,
range, costPerElement);
655 :
RangeJob(callback, range, costPerElement)
671 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.