ThreadWeaver 5.109.0
collection.h
1/* -*- C++ -*-
2 This file declares the Collection class.
3
4 SPDX-FileCopyrightText: 2004-2013 Mirko Boehm <mirko@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef JOBCOLLECTION_H
10#define JOBCOLLECTION_H
11
12#include "job.h"
13#include "jobpointer.h"
14
15namespace ThreadWeaver
16{
17class Thread;
18class CollectionExecuteWrapper;
19
20namespace Private
21{
22class Collection_Private;
23}
24
31class THREADWEAVER_EXPORT Collection : public Job
32{
33public:
34 Collection();
35 Collection(ThreadWeaver::Private::Collection_Private *d);
36 ~Collection() override;
37
44 virtual void addJob(JobPointer);
45
49 // FIXME remove job argument?
50 void stop(ThreadWeaver::JobPointer job);
51
53 int elementCount() const;
54
55#if THREADWEAVER_ENABLE_DEPRECATED_SINCE(5, 0)
57 THREADWEAVER_DEPRECATED_VERSION(5, 0, "Use Collection::elementCount()")
58 int jobListLength() const;
59#endif
60
62 Collection &operator<<(ThreadWeaver::JobInterface *job);
63
65 Collection &operator<<(const ThreadWeaver::JobPointer &job);
66 Collection &operator<<(JobInterface &job);
67
68protected:
70 void aboutToBeQueued_locked(QueueAPI *api) override;
71
73 void aboutToBeDequeued_locked(QueueAPI *api) override;
74
76 JobPointer jobAt(int i);
77
78 // FIXME remove
82 virtual int jobListLength_locked() const;
83
84protected:
86 void execute(const JobPointer &job, Thread *) override;
87
90 void run(JobPointer self, Thread *thread) override;
91
92protected:
93 friend class CollectionExecuteWrapper; // needs to access d()
94 friend class Collection_Private;
95 ThreadWeaver::Private::Collection_Private *d();
96 const ThreadWeaver::Private::Collection_Private *d() const;
97};
98
99}
100
101#endif
A Collection is a vector of Jobs that will be queued together.
Definition collection.h:32
int elementCount() const
Return the number of elements in the collection.
void stop(ThreadWeaver::JobPointer job)
Stop processing, dequeue all remaining Jobs.
void aboutToBeQueued_locked(QueueAPI *api) override
Overload to queue the collection.
void execute(const JobPointer &job, Thread *) override
Overload the execute method.
Collection & operator<<(ThreadWeaver::JobInterface *job)
Add the job to this collection by pointer.
virtual int jobListLength_locked() const
Return the number of jobs in the joblist.
void run(JobPointer self, Thread *thread) override
Overload run().
virtual void addJob(JobPointer)
Append a job to the collection.
void aboutToBeDequeued_locked(QueueAPI *api) override
Overload to dequeue the collection.
Collection & operator<<(const ThreadWeaver::JobPointer &job)
Add the job to this collection.
JobPointer jobAt(int i)
Return a ref-erence to the job in the job list at position i.
A Job is a simple abstraction of an action that is to be executed in a thread context.
Definition job.h:47
Thread represents a worker thread in a Queue's inventory.
Definition thread.h:28