KIO

scheduler.h
1// -*- c++ -*-
2/*
3 This file is part of the KDE libraries
4 SPDX-FileCopyrightText: 2000 Stephan Kulow <coolo@kde.org>
5 SPDX-FileCopyrightText: 2000 Waldo Bastian <bastian@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#ifndef _kio_scheduler_h
11#define _kio_scheduler_h
12
13#include "simplejob.h"
14#include <QMap>
15#include <QTimer>
16
17namespace KIO
18{
19class Worker;
20
21class SchedulerPrivate;
22/*
23 *
24 * The KIO::Scheduler manages KIO workers for the application.
25 * It also queues jobs and assigns the job to a worker when one
26 * becomes available.
27 *
28 * There are two possible ways for a job to get a worker:
29 *
30 * <h3>1. Direct</h3>
31 * This is the default. When you create a job the
32 * KIO::Scheduler will be notified and will find either an existing
33 * worker that is idle or it will create a new worker for the job.
34 *
35 *
36 * <h3>2. Scheduled</h3>
37 * If you create a lot of jobs, you might want not want to have a
38 * worker for each job. If you schedule a job, a maximum number
39 * of workers will be created. When more jobs arrive, they will be
40 * queued. When a worker is finished with a job, it will be assigned
41 * a job from the queue.
42 *
43 * @see KIO::Job
44 */
45class Scheduler : public QObject
46{
48 Q_CLASSINFO("D-Bus Interface", "org.kde.KIO.Scheduler")
49public:
50 /**
51 * Register @p job with the scheduler.
52 * The default is to create a new worker for the job if no worker
53 * is available.
54 * @param job the job to register
55 */
56 static void doJob(SimpleJob *job);
57
58 /**
59 * Stop the execution of a job.
60 * @param job the job to cancel
61 */
62 static void cancelJob(SimpleJob *job);
63
64 /**
65 * Called when a job is done.
66 * @param job the finished job
67 * @param worker the worker that executed the @p job
68 */
69 static void jobFinished(KIO::SimpleJob *job, KIO::Worker *worker);
70
71 /**
72 * Puts a worker on notice. A next job may reuse this worker if it
73 * requests the same URL.
74 *
75 * A job can be put on hold after it has emit'ed its mimetype() signal.
76 * Based on the MIME type, the program can give control to another
77 * component in the same process which can then resume the job
78 * by simply asking for the same URL again.
79 * @param job the job that should be stopped
80 * @param url the URL that is handled by the @p url
81 *
82 * @since 5.101
83 */
84 static void putWorkerOnHold(KIO::SimpleJob *job, const QUrl &url);
85
86 /**
87 * Removes any worker that might have been put on hold. If a worker
88 * was put on hold it will be killed.
89 *
90 * @since 5.101
91 */
92 static void removeWorkerOnHold();
93
94 static void emitReparseSlaveConfiguration();
95 // KF6 TODO: rename to emitReparseWorkerConfiguration. See also T15956.
96
97 /**
98 * Returns true if there is a worker on hold for @p url.
99 *
100 * @since 5.101
101 */
102 static bool isWorkerOnHoldFor(const QUrl &url);
103
104 /**
105 * Updates the internal metadata from job.
106 *
107 * @since 4.6.5
108 */
109 static void updateInternalMetaData(SimpleJob *job);
110
112
113 // DBUS
114 Q_SCRIPTABLE void reparseSlaveConfiguration(const QString &);
115 // KF6 TODO: rename to reparseWorkerConfiguration. See also T15956.
116
117private:
118 Q_DISABLE_COPY(Scheduler)
119 KIOCORE_NO_EXPORT Scheduler();
120 KIOCORE_NO_EXPORT ~Scheduler() override;
121
122 KIOCORE_NO_EXPORT static Scheduler *self();
123
124 // connected to D-Bus signal:
125#ifdef WITH_QTDBUS
126 Q_PRIVATE_SLOT(d_func(), void slotReparseSlaveConfiguration(const QString &, const QDBusMessage &))
127#endif
128
129private:
130 friend class SchedulerPrivate;
131 KIOCORE_NO_EXPORT SchedulerPrivate *d_func();
132};
133
134}
135#endif
A namespace for KIO globals.
Q_CLASSINFO(Name, Value)
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:49:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.