KIO::Scheduler Class Reference
The KIO::Scheduler manages io-slaves for the application. More...
#include <scheduler.h>
Inheritance diagram for KIO::Scheduler:

Public Types | |
typedef QPtrList< SimpleJob > | JobList |
Public Slots | |
void | slotSlaveDied (KIO::Slave *slave) |
void | slotSlaveStatus (pid_t pid, const QCString &protocol, const QString &host, bool connected) |
Signals | |
void | slaveConnected (KIO::Slave *slave) |
void | slaveError (KIO::Slave *slave, int error, const QString &errorMsg) |
Public Member Functions | |
bool | connect (const QObject *sender, const char *signal, const char *member) |
void | debug_info () |
virtual bool | process (const QCString &fun, const QByteArray &data, QCString &replyType, QByteArray &replyData) |
virtual QCStringList | functions () |
Static Public Member Functions | |
static void | doJob (SimpleJob *job) |
static void | scheduleJob (SimpleJob *job) |
static void | cancelJob (SimpleJob *job) |
static void | jobFinished (KIO::SimpleJob *job, KIO::Slave *slave) |
static void | putSlaveOnHold (KIO::SimpleJob *job, const KURL &url) |
static void | removeSlaveOnHold () |
static void | publishSlaveOnHold () |
static KIO::Slave * | getConnectedSlave (const KURL &url, const KIO::MetaData &config=MetaData()) |
static bool | assignJobToSlave (KIO::Slave *slave, KIO::SimpleJob *job) |
static bool | disconnectSlave (KIO::Slave *slave) |
static void | registerWindow (QWidget *wid) |
static void | unregisterWindow (QObject *wid) |
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 void | checkSlaveOnHold (bool b) |
Protected Slots | |
void | startStep () |
void | slotCleanIdleSlaves () |
void | slotSlaveConnected () |
void | slotSlaveError (int error, const QString &errorMsg) |
void | slotScheduleCoSlave () |
void | slotUnregisterWindow (QObject *) |
Protected Member Functions | |
void | setupSlave (KIO::Slave *slave, const KURL &url, const QString &protocol, const QString &proxy, bool newSlave, const KIO::MetaData *config=0) |
bool | startJobScheduled (ProtocolInfo *protInfo) |
bool | startJobDirect () |
virtual void | virtual_hook (int id, void *data) |
Detailed Description
The KIO::Scheduler manages io-slaves for the application.It also queues jobs and assigns the job to a slave when one becomes available.
There are 3 possible ways for a job to get a slave:
1. Direct
This is the default. When you create a job the KIO::Scheduler will be notified and will find either an existing slave that is idle or it will create a new slave for the job.
Example:
2. Scheduled
If you create a lot of jobs, you might want not want to have a slave for each job. If you schedule a job, a maximum number of slaves will be created. When more jobs arrive, they will be queued. When a slave is finished with a job, it will be assigned a job from the queue.
Example:
TransferJob *job = KIO::get(KURL("http://www.kde.org")); KIO::Scheduler::scheduleJob(job);
3. Connection Oriented
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:
Slave *slave = KIO::Scheduler::getConnectedSlave( KURL("pop3://bastian:password@mail.kde.org")); TransferJob *job1 = KIO::get( KURL("pop3://bastian:password@mail.kde.org/msg1")); KIO::Scheduler::assignJobToSlave(slave, job1); TransferJob *job2 = KIO::get( KURL("pop3://bastian:password@mail.kde.org/msg2")); KIO::Scheduler::assignJobToSlave(slave, job2); TransferJob *job3 = KIO::get( KURL("pop3://bastian:password@mail.kde.org/msg3")); KIO::Scheduler::assignJobToSlave(slave, job3); // ... Wait for jobs to finish... KIO::Scheduler::disconnectSlave(slave);
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)
KIO::Scheduler::disconnectSlave(slave);
- See also:
- KIO::Slave
Definition at line 111 of file scheduler.h.
Member Function Documentation
|
Register The default is to create a new slave for the job if no slave is available. This can be changed by calling scheduleJob.
Definition at line 129 of file scheduler.h. Referenced by KIO::SimpleJob::SimpleJob(), KIO::MultiGetJob::slotFinished(), KIO::ListJob::slotFinished(), KIO::MimetypeJob::slotFinished(), KIO::TransferJob::slotFinished(), KIO::StatJob::slotFinished(), and KIO::MkdirJob::slotFinished(). |
|
Calling ths function makes that
Definition at line 138 of file scheduler.h. Referenced by KIO::DeleteJob::slotResult(). |
|
Stop the execution of a job.
Definition at line 145 of file scheduler.h. Referenced by KIO::SimpleJob::kill(). |
|
Called when a job is done.
Definition at line 153 of file scheduler.h. |
|
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. Based on the mimetype, 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.
Definition at line 167 of file scheduler.h. Referenced by KIO::SimpleJob::putOnHold(). |
|
Removes any slave that might have been put on hold. If a slave was put on hold it will be killed. Definition at line 174 of file scheduler.h. Referenced by KIO::SimpleJob::removeOnHold(). |
|
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. Definition at line 182 of file scheduler.h. Referenced by KRun::foundMimeType(). |
|
Requests a slave for use in connection-oriented mode.
Definition at line 196 of file scheduler.h. |
|
Send the slave that was put on hold back to KLauncher.
This allows another process to take over the slave and resume the job the that was started. Register the mainwindow
Definition at line 243 of file scheduler.h. |
|
Function to connect signals emitted by the scheduler.
Definition at line 259 of file scheduler.h. |
|
When true, the next job will check whether KLauncher has a slave on hold that is suitable for the job.
Definition at line 280 of file scheduler.h. |
|
Definition at line 887 of file scheduler.cpp. |
The documentation for this class was generated from the following files: