34class THREADWEAVER_EXPORT
Weaver :
public QueueAPI
38 explicit Weaver(QObject *parent =
nullptr);
41 void shutDown_p()
override;
44 State *state()
override;
50 void setState(StateId);
51 void enqueue(
const QVector<JobPointer> &jobs)
override;
52 bool dequeue(
const JobPointer &job)
override;
60 JobPointer applyForWork(
Thread *thread,
bool wasBusy)
override;
61 void waitForAvailableJob(
Thread *th)
override;
62 void blockThreadUntilJobsAreBeingAssigned(
Thread *th);
63 void blockThreadUntilJobsAreBeingAssigned_locked(
Thread *th);
64 void incActiveThreadCount();
65 void decActiveThreadCount();
66 int activeThreadCount();
68 void threadEnteredRun(
Thread *thread);
69 JobPointer takeFirstAvailableJobOrSuspendOrWait(
Thread *th,
bool threadWasBusy,
bool suspendIfAllThreadsInactive,
bool justReturning);
76 void setState_p(StateId);
77 void setMaximumNumberOfThreads_p(
int cap)
override;
78 int maximumNumberOfThreads_p()
const override;
79 int currentNumberOfThreads_p()
const override;
80 void enqueue_p(
const QVector<JobPointer> &jobs);
81 bool dequeue_p(JobPointer job)
override;
82 void dequeue_p()
override;
83 void finish_p()
override;
84 void suspend_p()
override;
85 void resume_p()
override;
86 bool isEmpty_p()
const override;
87 bool isIdle_p()
const override;
88 int queueLength_p()
const override;
89 void requestAbort_p()
override;
100 void adjustActiveThreadCount(
int diff);
101 virtual Thread *createThread();
102 void adjustInventory(
int noOfNewJobs);
105 ThreadWeaver::Private::Weaver_Private *d();
106 const ThreadWeaver::Private::Weaver_Private *d()
const;
We use a State pattern to handle the system state in ThreadWeaver.
Definition state.h:56
SuspendingState is the state after suspend() has been called, but before all threads finished executi...
Definition suspendingstate.h:23
Thread represents a worker thread in a Queue's inventory.
Definition thread.h:28
Base class for all WeaverImpl states.
Definition weaverimplstate.h:21
A Weaver manages worker threads.
Definition weaver.h:35
void setMaximumNumberOfThreads(int cap) override
Set the maximum number of threads this Weaver object may start.
void threadSuspended(ThreadWeaver::Thread *)
A thread has been suspended.
void finish() override
Finish all queued operations, then return.
bool isEmpty() const override
Is the queue empty? The queue is empty if no more jobs are queued.
void dequeue() override
Remove all queued jobs.
void reschedule() override
Reschedule the jobs in the queue.
bool isIdle() const override
Is the weaver idle? The weaver is idle if no jobs are queued and no jobs are processed by the threads...
void resume() override
Resume job queueing.
void requestAbort() override
Request aborts of the currently executed jobs.
const State * state() const override
Return the state of the weaver object.
int currentNumberOfThreads() const override
Returns the current number of threads in the inventory.
void shutDown() override
Shut down the queue.
void threadExited(ThreadWeaver::Thread *)
A thread has exited.
void threadStarted(ThreadWeaver::Thread *)
A Thread has been created.
void enqueue(const QVector< JobPointer > &jobs) override
Queue a vector of jobs.
int maximumNumberOfThreads() const override
Get the maximum number of threads this Weaver may start.
bool dequeue(const JobPointer &job) override
Remove a job from the queue.
int queueLength() const override
Returns the number of pending jobs.
void suspend() override
Suspend job execution.