ThreadWeaver 5.109.0
Public Member Functions | Protected Member Functions | List of all members
ThreadWeaver::Lambda< T >

Lambda is a template that takes any type on which operator() is available, and executes it in run(). More...

#include <lambda.h>

Public Member Functions

 Lambda (T t_)
 
- 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 run (JobPointer, Thread *) override
 The method that actually performs the job.
 
- 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

template<typename T>
class ThreadWeaver::Lambda< T >

Lambda is a template that takes any type on which operator() is available, and executes it in run().

Member Function Documentation

◆ run()

template<typename T >
void ThreadWeaver::Lambda< T >::run ( JobPointer  self,
Thread thread 
)
inlineoverrideprotectedvirtual

The method that actually performs the job.

It is called from execute(). This method is the one to overload it with the job's task.

The Job will be executed in the specified thread. thread may be zero, indicating that the job is being executed some other way (for example, synchronously by some other job). self specifies the job as the queue sees it. Whenever publishing information about the job to the outside world, for example by emitting signals, use self, not this. self is the reference counted object handled by the queue. Using it as signal parameters will amongst other things prevent thejob from being memory managed and deleted.

Implements ThreadWeaver::Job.