KIO::Scheduler

Search for usage in LXR

#include <KIO/Scheduler>

Inheritance diagram for KIO::Scheduler:

Signals

Q_SCRIPTABLE void reparseSlaveConfiguration (const QString &)
 
QT_MOC_COMPAT void slaveConnected (KIO::Slave *slave)
 
QT_MOC_COMPAT void slaveError (KIO::Slave *slave, int error, const QString &errorMsg)
 
Q_SCRIPTABLE void slaveOnHoldListChanged ()
 

Public Member Functions

bool connect (const QObject *sender, const char *signal, const char *member)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static bool assignJobToSlave (KIO::Slave *slave, KIO::SimpleJob *job)
 
static void cancelJob (SimpleJob *job)
 
static void checkSlaveOnHold (bool b)
 
static bool connect (const char *signal, const QObject *receiver, const char *member)
 
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 
static bool disconnectSlave (KIO::Slave *slave)
 
static void doJob (SimpleJob *job)
 
static void emitReparseSlaveConfiguration ()
 
static KIO::Slave * getConnectedSlave (const QUrl &url, const KIO::MetaData &config=MetaData())
 
static bool isSlaveOnHoldFor (const QUrl &url)
 
static bool isWorkerOnHoldFor (const QUrl &url)
 
static void jobFinished (KIO::SimpleJob *job, KIO::Slave *slave)
 
static void publishSlaveOnHold ()
 
static void putSlaveOnHold (KIO::SimpleJob *job, const QUrl &url)
 
static void putWorkerOnHold (KIO::SimpleJob *job, const QUrl &url)
 
static void removeSlaveOnHold ()
 
static void removeWorkerOnHold ()
 
static void scheduleJob (SimpleJob *job)
 
static void setJobPriority (SimpleJob *job, int priority)
 
static void updateInternalMetaData (SimpleJob *job)
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

The KIO::Scheduler manages KIO workers for the application. It also queues jobs and assigns the job to a worker when one becomes available.

There are 3 possible ways for a job to get a worker:

1. Direct

This is the default. When you create a job the KIO::Scheduler will be notified and will find either an existing worker that is idle or it will create a new worker for the job.

Example:

TransferJob *job = KIO::get(QUrl("https://www.kde.org"));

2. Scheduled

If you create a lot of jobs, you might want not want to have a worker for each job. If you schedule a job, a maximum number of workers will be created. When more jobs arrive, they will be queued. When a worker is finished with a job, it will be assigned a job from the queue.

Example:

TransferJob *job = KIO::get(QUrl("https://www.kde.org"));

3. Connection Oriented (TODO KF6 remove this section)

For some operations it is important that multiple jobs use the same connection. This can only be ensured if all these jobs use the same slave.

You can ask the scheduler to open a slave for connection oriented operations. You can then use the scheduler to assign jobs to this slave. The jobs will be queued and the slave will handle these jobs one after the other.

Example:

QUrl("pop3://bastian:[email protected]"));
TransferJob *job1 = KIO::get(
QUrl("pop3://bastian:[email protected]/msg1"));
TransferJob *job2 = KIO::get(
QUrl("pop3://bastian:[email protected]/msg2"));
TransferJob *job3 = KIO::get(
QUrl("pop3://bastian:[email protected]/msg3"));
// ... Wait for jobs to finish...

Note that you need to explicitly disconnect the slave when the connection goes down, so your error handler should contain:

if (error == KIO::ERR_CONNECTION_BROKEN)
See also
KIO::Slave
KIO::Job

Definition at line 98 of file scheduler.h.

Member Function Documentation

◆ assignJobToSlave()

bool Scheduler::assignJobToSlave ( KIO::Slave *  slave,
KIO::SimpleJob job 
)
static

Uses slave to do job.

This function should be called immediately after creating a Job.

Parameters
slaveThe slave to use. The slave must have been obtained with a call to getConnectedSlave and must not be currently assigned to any other job.
jobThe job to do.
Returns
true is successful, false otherwise.
See also
getConnectedSlave()
disconnectSlave()
slaveConnected()
slaveError()
Deprecated:
since 5.91 Port away from the connected slave feature, e.g. making a library out of the slave code.

Definition at line 858 of file scheduler.cpp.

◆ cancelJob()

void Scheduler::cancelJob ( SimpleJob job)
static

Stop the execution of a job.

Parameters
jobthe job to cancel

Definition at line 795 of file scheduler.cpp.

◆ checkSlaveOnHold()

void Scheduler::checkSlaveOnHold ( bool  b)
static

When true, the next job will check whether KLauncher has a slave on hold that is suitable for the job.

Parameters
btrue when KLauncher has a job on hold
Deprecated:
since 5.88, the feature of holding slaves between processes is gone, just remove the call

Definition at line 898 of file scheduler.cpp.

◆ connect()

bool Scheduler::connect ( const char *  signal,
const QObject receiver,
const char *  member 
)
static

Function to connect signals emitted by the scheduler.

See also
slaveConnected()
slaveError()
Deprecated:
Since 5.103, due to no known users.

Definition at line 870 of file scheduler.cpp.

◆ disconnectSlave()

bool Scheduler::disconnectSlave ( KIO::Slave *  slave)
static

Disconnects slave.

Parameters
slaveThe slave to disconnect. The slave must have been obtained with a call to getConnectedSlave and must not be assigned to any job.
Returns
true is successful, false otherwise.
See also
getConnectedSlave
assignJobToSlave
Deprecated:
since 5.91 Port away from the connected slave feature, e.g. making a library out of the slave code.

Definition at line 863 of file scheduler.cpp.

◆ doJob()

void Scheduler::doJob ( SimpleJob job)
static

Register job with the scheduler.

The default is to create a new worker for the job if no worker is available. This can be changed by calling setJobPriority.

Parameters
jobthe job to register

Definition at line 770 of file scheduler.cpp.

◆ getConnectedSlave()

KIO::Slave * Scheduler::getConnectedSlave ( const QUrl url,
const KIO::MetaData config = MetaData() 
)
static

Requests a slave for use in connection-oriented mode.

Parameters
urlThis defines the username,password,host & port to connect with.
configConfiguration data for the slave.
Returns
A pointer to a connected slave or nullptr if an error occurred.
See also
assignJobToSlave()
disconnectSlave()
Deprecated:
since 5.91 Port away from the connected slave feature, e.g. making a library out of the slave code.

Definition at line 853 of file scheduler.cpp.

◆ isSlaveOnHoldFor()

bool Scheduler::isSlaveOnHoldFor ( const QUrl url)
static

Returns true if there is a slave on hold for url.

Since
4.7
Deprecated:
Since 5.101, use isWorkerOnHoldFor(const QUrl &)

Definition at line 836 of file scheduler.cpp.

◆ isWorkerOnHoldFor()

bool Scheduler::isWorkerOnHoldFor ( const QUrl url)
static

Returns true if there is a worker on hold for url.

Since
5.101

Definition at line 842 of file scheduler.cpp.

◆ jobFinished()

void Scheduler::jobFinished ( KIO::SimpleJob job,
KIO::Slave *  slave 
)
static

Called when a job is done.

Parameters
jobthe finished job
slavethe slave that executed the job

Definition at line 800 of file scheduler.cpp.

◆ publishSlaveOnHold()

void Scheduler::publishSlaveOnHold ( )
static

Send the slave that was put on hold back to KLauncher.

This allows another process to take over the slave and resume the job that was started.

Deprecated:
since 5.88, the feature of holding slaves between processes is gone, just remove the call

Definition at line 830 of file scheduler.cpp.

◆ putSlaveOnHold()

void Scheduler::putSlaveOnHold ( KIO::SimpleJob job,
const QUrl url 
)
static

Puts a slave on notice.

A next job may reuse this slave if it requests the same URL.

A job can be put on hold after it has emit'ed its mimetype() signal. Based on the MIME type, the program can give control to another component in the same process which can then resume the job by simply asking for the same URL again.

Parameters
jobthe job that should be stopped
urlthe URL that is handled by the url
Deprecated:
Since 5.101, use putWorkerOnHold(KIO::SimpleJob *, const QUrl &)

Definition at line 806 of file scheduler.cpp.

◆ putWorkerOnHold()

void Scheduler::putWorkerOnHold ( KIO::SimpleJob job,
const QUrl url 
)
static

Puts a worker on notice.

A next job may reuse this worker if it requests the same URL.

A job can be put on hold after it has emit'ed its mimetype() signal. Based on the MIME type, the program can give control to another component in the same process which can then resume the job by simply asking for the same URL again.

Parameters
jobthe job that should be stopped
urlthe URL that is handled by the url
Since
5.101

Definition at line 812 of file scheduler.cpp.

◆ removeSlaveOnHold()

void Scheduler::removeSlaveOnHold ( )
static

Removes any slave that might have been put on hold.

If a slave was put on hold it will be killed.

Deprecated:
Since 5.101, use removeWorkerOnHold()

Definition at line 818 of file scheduler.cpp.

◆ removeWorkerOnHold()

void Scheduler::removeWorkerOnHold ( )
static

Removes any worker that might have been put on hold.

If a worker was put on hold it will be killed.

Since
5.101

Definition at line 824 of file scheduler.cpp.

◆ scheduleJob()

void Scheduler::scheduleJob ( SimpleJob job)
static

Schedules job scheduled for later execution.

This method is deprecated and just sets the job's priority to 1. It is recommended to replace calls to scheduleJob(job) with setJobPriority(job, 1).

Parameters
jobthe job to schedule
Deprecated:
Since 4.5, use setJobPriority(SimpleJob *job, int priority)

Definition at line 776 of file scheduler.cpp.

◆ setJobPriority()

void Scheduler::setJobPriority ( SimpleJob job,
int  priority 
)
static

Changes the priority of job; jobs of the same priority run in the order in which they were created.

Jobs of lower numeric priority always run before any waiting jobs of higher numeric priority. The range of priority is -10 to 10, the default priority of jobs is 0.

Parameters
jobthe job to change
prioritynew priority of job, lower runs earlier
Deprecated:
Since 5.90. Changing priorities was only used by KHTML. If you need this, please contact kde-frameworks-devel to request the feature back, but as better API like Job::setPriority.

Definition at line 783 of file scheduler.cpp.

◆ slaveConnected

QT_MOC_COMPAT void KIO::Scheduler::slaveConnected ( KIO::Slave *  slave)
signal
Deprecated:
since 5.91 Port away from the connected slave feature, e.g.

making a library out of the slave code.

◆ slaveError

QT_MOC_COMPAT void KIO::Scheduler::slaveError ( KIO::Slave *  slave,
int  error,
const QString errorMsg 
)
signal
Deprecated:
since 5.91 Port away from the connected slave feature, e.g.

making a library out of the slave code.

◆ slaveOnHoldListChanged

Q_SCRIPTABLE void KIO::Scheduler::slaveOnHoldListChanged ( )
signal
Deprecated:
since 5.91 Port away from the connected slave feature, e.g.

making a library out of the slave code.

◆ updateInternalMetaData()

void Scheduler::updateInternalMetaData ( SimpleJob job)
static

Updates the internal metadata from job.

Since
4.6.5

Definition at line 847 of file scheduler.cpp.


The documentation for this class was generated from the following files:
static void setJobPriority(SimpleJob *job, int priority)
Changes the priority of job; jobs of the same priority run in the order in which they were created.
Definition: scheduler.cpp:783
static KIO::Slave * getConnectedSlave(const QUrl &url, const KIO::MetaData &config=MetaData())
Requests a slave for use in connection-oriented mode.
Definition: scheduler.cpp:853
static bool disconnectSlave(KIO::Slave *slave)
Disconnects slave.
Definition: scheduler.cpp:863
KIOCORE_EXPORT TransferJob * get(const QUrl &url, LoadType reload=NoReload, JobFlags flags=DefaultFlags)
Get (means: read).
static bool assignJobToSlave(KIO::Slave *slave, KIO::SimpleJob *job)
Uses slave to do job.
Definition: scheduler.cpp:858
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:54:45 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.