21 # pragma warning(push)
22 # pragma warning(disable:4355) // Disable warnings about passing the 'this' pointer to base class constructors.
23 # pragma warning(disable: 6011) // Disable warningC6011: dereferencing nullptr pointer
69 Job& operator=(
const Job& other);
78 void addDependency(
Job *parent);
84 void removeDependency(
Job *parent);
90 bool hasDependency(
Job *parent);
96 void removeAllDependencies();
102 void clearChildDependencies();
108 void setNumDependencies(
agx::UInt32 numDependencies);
118 void incrementNumDependencies(
agx::UInt32 size = 1);
123 void decrementNumDependencies(
agx::UInt32 size = 1);
138 void setCallback(
const Delegate& callback);
143 const Delegate& getCallback()
const;
160 Thread *getTargetThread();
165 void setTargetThread(
Thread *thread);
175 void setTask(
Task *task);
180 SyncTag *getSyncTag();
185 void setSyncTag(SyncTag *tag);
190 Real getExecutionTime()
const;
195 const Timer& getTimer()
const;
210 Thread *getAssignedThread();
226 void setName(
const char *name);
231 const char *getName()
const;
245 virtual void implementation();
305 virtual void implementation()
override;
347 void addJob(
Job *job);
353 virtual void implementation()
override;
384 const Job *getTarget()
const;
422 m_numDependencies(0),
423 m_dependencyCounter(0),
425 m_targetThread(nullptr),
426 m_assignedThread(nullptr),
435 m_name(other.m_name),
436 m_children(other.m_children),
437 m_parents(other.m_parents),
438 m_callback(other.m_callback),
439 m_timer(other.m_timer),
440 m_numDependencies(other.m_numDependencies),
441 m_dependencyCounter(other.m_dependencyCounter.load()),
442 m_task(other.m_task),
443 m_targetThread(other.m_targetThread),
444 m_assignedThread(other.m_assignedThread),
445 m_syncTag(other.m_syncTag),
446 m_cost(other.m_cost),
448 m_index(other.m_index)
457 m_callback(callback),
458 m_numDependencies(0),
459 m_dependencyCounter(0),
461 m_targetThread(nullptr),
462 m_assignedThread(nullptr),
463 m_cost(costEstimate),
616 this->
init(callback, range, costPerElement);
656 :
RangeJob(callback, range, costPerElement)
672 static_cast<T *
>(m_task)->dispatch(*
this);
709 # pragma warning(pop)
void AGXPHYSICS_EXPORT init()
Initialize agx.
Real getExecutionTime() const
void push_back(const T &value)
agx::Thread is a representation of an OS specific implementation of a computational thread...
bool contains(const T2 &element) const
Test if the vector contains a certain element.
const JobPtrVector & getChildDependencies() const
agx::Callback1< const RangeJob & > RangeDelegate
An abstract job/workblock representation, which allows work threads to execute arbitrary tasks...
void init(const Delegate &callback=Delegate(), agx::UInt32 costEstimate=100)
Initialize the job.
A job used as a synchronization utility when waiting for another job to complete. ...
void setCostEstimate(agx::UInt32 cost)
Specify the cost estimate for this job.
Generalized callback, using std::function.
void removeAllDependencies()
Remove all parent dependencies.
#define AGX_TYPE_BINDING(_Type, _Name)
void setTargetThread(Thread *thread)
Set the target thread which the job will be executed on.
bool hasDependency(Job *parent)
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
const JobPtrVector & getParentDependencies() const
void setTag(agx::UInt32 tag)
Set the job tag, can be used to keep track of different job classes etc.
A representation of a generic task.
The Timer class permits timing execution speed with the same refinement as the built in hardware cloc...
const Timer & getTimer() const
Block synchronization primitive.
A range job executes a kernel implementation on a subset of the data.
void removeDependency(Job *parent)
Remove a dependency from a job.
const char * getName() const
const Delegate & getCallback() const
Return the current callback.
VectorPOD< class Job * > JobPtrVector
void setCallback(const Delegate &callback)
Set the callback which is called when execute() runs.
Thread * getAssignedThread()
RangeJob & operator=(const RangeJob &other)
A task job is a job which executes an agx::Task.
Job & operator=(const Job &other)
virtual void implementation() override
Job implementation, override in subclass.
A group of jobs to be executed.
Templated callback with one argument.
void setNumDependencies(agx::UInt32 numDependencies)
Explicitly set the number of parent dependencies.
void setName(const char *name)
Set the name of the job, for debugging.
Real64 getTime() const
Report total elapsed time since start in milliseconds, excluding intervals when the timer was suspend...
bool findAndErase(const T &element, bool searchMultiple=false)
Find and erase an element.
void incrementNumDependencies(agx::UInt32 size=1)
Explicitly increment the number of parent dependencies.
agx::UInt32 getNumDependencies() const
RangeCallback m_rangeCallback
void clearChildDependencies()
Remove all child dependencies.
agx::UInt32 getTag() const
void clear(ClearPolicy policy=SHRINK_BUFFER_AVERAGED)
Remove all elements, optionally with maintained buffer allocation.
agx::UInt32 m_numDependencies
void decrementNumDependencies(agx::UInt32 size=1)
Explicitly decrement the number of parent dependencies.
const JobPtrVector & getSubJobs() const
agx::UInt32 getCostEstimate() const
Vector< RangeJob > RangeJobVector
std::atomic< Int32 > m_dependencyCounter
void setTask(Task *task)
Set the task which the job belongs to.
std::deque< class Job * > JobPtrQueue
void addDependency(Job *parent)
Add a dependency to a job.
Thread * getTargetThread()
Thread * m_assignedThread
void setSyncTag(SyncTag *tag)
Set the synchronization tag which must enter completion status before the job is executed.
void init(const RangeCallback &callback, const IndexRange &range, agx::UInt32 costPerElement=1)