ThreadWeaver 5.109.0
Public Member Functions | Protected Member Functions | List of all members
ThreadWeaver::Collection

A Collection is a vector of Jobs that will be queued together. More...

#include <collection.h>

Public Member Functions

 Collection (ThreadWeaver::Private::Collection_Private *d)
 
virtual void addJob (JobPointer)
 Append a job to the collection.
 
int elementCount () const
 Return the number of elements in the collection.
 
int jobListLength () const
 
Collectionoperator<< (const ThreadWeaver::JobPointer &job)
 Add the job to this collection.
 
Collectionoperator<< (JobInterface &job)
 
Collectionoperator<< (ThreadWeaver::JobInterface *job)
 Add the job to this collection by pointer.
 
void stop (ThreadWeaver::JobPointer job)
 Stop processing, dequeue all remaining Jobs.
 
- Public Member Functions inherited from ThreadWeaver::Job
 Job ()
 Construct a Job.
 
 Job (Private::Job_Private *d)
 
 ~Job () override
 Destructor.
 
void aboutToBeDequeued (QueueAPI *api) override
 This Job is about the be dequeued from the weaver's job queue.
 
void aboutToBeDequeued_locked (QueueAPI *api) override
 Called from aboutToBeDequeued() while the mutex is being held.
 
void aboutToBeQueued (QueueAPI *api) override
 The job is about to be added to the weaver's job queue.
 
void aboutToBeQueued_locked (QueueAPI *api) override
 Called from aboutToBeQueued() while the mutex is being held.
 
void assignQueuePolicy (QueuePolicy *) override
 Assign a queue policy.
 
void blockingExecute () override
 Perform the job synchronously in the current thread.
 
void execute (const JobPointer &job, Thread *) override
 Perform the job.
 
Executor * executor () const override
 Returns the executor currently set on the Job.
 
bool isFinished () const override
 Returns true if the jobs's execute method finished.
 
QMutex * mutex () const override
 The mutex used to protect this job.
 
int priority () const override
 The queueing priority of the job.
 
QList< QueuePolicy * > queuePolicies () const override
 Return the queue policies assigned to this Job.
 
void removeQueuePolicy (QueuePolicy *) override
 Remove a queue policy from this job.
 
void requestAbort () override
 Abort the execution of the job.
 
Executor * setExecutor (Executor *executor) override
 Set the Executor object that is supposed to run the job.
 
void setStatus (Status) override
 Set the status of the Job.
 
Status status () const override
 The status of the job.
 
bool success () const override
 Return whether the Job finished successfully or not.
 

Protected Member Functions

void aboutToBeDequeued_locked (QueueAPI *api) override
 Overload to dequeue the collection.
 
void aboutToBeQueued_locked (QueueAPI *api) override
 Overload to queue the collection.
 
ThreadWeaver::Private::Collection_Private * d ()
 
const ThreadWeaver::Private::Collection_Private * d () const
 
void execute (const JobPointer &job, Thread *) override
 Overload the execute method.
 
JobPointer jobAt (int i)
 Return a ref-erence to the job in the job list at position i.
 
virtual int jobListLength_locked () const
 Return the number of jobs in the joblist.
 
void run (JobPointer self, Thread *thread) override
 Overload run().
 
- Protected Member Functions inherited from ThreadWeaver::Job
Private::Job_Private * d ()
 
const Private::Job_Private * d () const
 
void defaultBegin (const JobPointer &job, Thread *thread) override
 Perform standard tasks before starting the execution of a job.
 
void defaultEnd (const JobPointer &job, Thread *thread) override
 Perform standard task after the execution of a job.
 
virtual void run (JobPointer self, Thread *thread) override=0
 The method that actually performs the job.
 

Detailed Description

A Collection is a vector of Jobs that will be queued together.

In a Collection, the order of execution of the elements is not specified.

It is intended that the collection is set up first and then queued. After queuing, no further jobs should be added to the collection.

Member Function Documentation

◆ aboutToBeDequeued_locked()

void ThreadWeaver::Collection::aboutToBeDequeued_locked ( QueueAPI *  api)
overrideprotected

Overload to dequeue the collection.

◆ aboutToBeQueued_locked()

void ThreadWeaver::Collection::aboutToBeQueued_locked ( QueueAPI *  api)
overrideprotected

Overload to queue the collection.

◆ addJob()

virtual void ThreadWeaver::Collection::addJob ( JobPointer  )
virtual

Append a job to the collection.

To use Collection, create the Job objects first, add them to the collection, and then queue it. After the collection has been queued, no further Jobs are supposed to be added.

Note
Once the job has been added, execute wrappers can no more be set on it

◆ elementCount()

int ThreadWeaver::Collection::elementCount ( ) const

Return the number of elements in the collection.

◆ execute()

void ThreadWeaver::Collection::execute ( const JobPointer &  job,
Thread  
)
overrideprotected

Overload the execute method.

◆ jobAt()

JobPointer ThreadWeaver::Collection::jobAt ( int  i)
protected

Return a ref-erence to the job in the job list at position i.

◆ jobListLength()

int ThreadWeaver::Collection::jobListLength ( ) const
Deprecated:
Since 5.0, use elementCount().

◆ jobListLength_locked()

virtual int ThreadWeaver::Collection::jobListLength_locked ( ) const
protectedvirtual

Return the number of jobs in the joblist.

Assumes that the mutex is being held.

◆ operator<<() [1/2]

Collection & ThreadWeaver::Collection::operator<< ( const ThreadWeaver::JobPointer &  job)

Add the job to this collection.

◆ operator<<() [2/2]

Collection & ThreadWeaver::Collection::operator<< ( ThreadWeaver::JobInterface *  job)

Add the job to this collection by pointer.

◆ run()

void ThreadWeaver::Collection::run ( JobPointer  self,
Thread thread 
)
overrideprotectedvirtual

Overload run().

We have to.

Implements ThreadWeaver::Job.

◆ stop()

void ThreadWeaver::Collection::stop ( ThreadWeaver::JobPointer  job)

Stop processing, dequeue all remaining Jobs.

job is supposed to be an element of the collection.