ThreadWeaver 5.109.0
resourcerestrictionpolicy.h
1/* -*- C++ -*-
2 This file declares the ResourceRestrictionPolicy class.
3
4 SPDX-FileCopyrightText: 2004-2013 Mirko Boehm <mirko@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7
8 $Id: Job.h 32 2005-08-17 08:38:01Z mirko $
9*/
10
11#ifndef RESOURCE_RESTRICTION_POLICY_H
12#define RESOURCE_RESTRICTION_POLICY_H
13
14#include <QtGlobal>
15
16#include "jobpointer.h"
17#include "queuepolicy.h"
18
19namespace ThreadWeaver
20{
21class JobInterface;
22
35class THREADWEAVER_EXPORT ResourceRestrictionPolicy : public QueuePolicy
36{
37public:
38 explicit ResourceRestrictionPolicy(int cap = 0);
40
47 void setCap(int newCap);
48 int cap() const;
49 bool canRun(JobPointer) override;
50 void free(JobPointer) override;
51 void release(JobPointer) override;
52 void destructed(JobInterface *job) override;
53
54private:
55 class Private;
56 Private *const d;
57};
58
59}
60
61#endif // RESOURCE_RESTRICTION_POLICY_H
QueuePolicy is an interface for customizations of the queueing behaviour of jobs.
Definition queuepolicy.h:39
ResourceRestrictionPolicy is used to limit the number of concurrent accesses to the same resource.
Definition resourcerestrictionpolicy.h:36
void destructed(JobInterface *job) override
destructing() is called when a Job that has this queue policy assigned gets destructed.
void setCap(int newCap)
Cap the number of simultaneously executing jobs.
void free(JobPointer) override
free() is called after the job has been executed.
void release(JobPointer) override
release() is called if canRun() returned true, but the job has not been executed for external reasons...
bool canRun(JobPointer) override
canRun() is called before the job is executed.