Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

KIO::Scheduler Class Reference

#include <scheduler.h>

Inheritance diagram for KIO::Scheduler:

DCOPObject List of all members.

Public Methods

virtual bool process (const QCString &fun, const QByteArray &data, QCString &replyType, QByteArray &replyData)
virtual QCStringList functions ()

Static Public Methods

void doJob (SimpleJob *job)
void scheduleJob (SimpleJob *job)
void cancelJob (SimpleJob *job)
void jobFinished (KIO::SimpleJob *job, KIO::Slave *slave)
void putSlaveOnHold (KIO::SimpleJob *job, const KURL &url)
void removeSlaveOnHold ()
void publishSlaveOnHold ()
KIO::Slave * getConnectedSlave (const KURL &url, const KIO::MetaData &config=MetaData())
void registerWindow (QWidget *wid)
bool connect (const char *signal, const QObject *receiver, const char *member)
void checkSlaveOnHold (bool b)

Protected Slots

void slotUnregisterWindow (QObject *)
 
Since:
3.1



Protected Methods

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: TransferJob *job = KIO::get(KURL("http://www.kde.org"));

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);
 

Definition at line 99 of file scheduler.h.


Member Function Documentation

void KIO::Scheduler::cancelJob SimpleJob   job [inline, static]
 

Stop the execution of a job.

Definition at line 130 of file scheduler.h.

References _cancelJob().

void KIO::Scheduler::checkSlaveOnHold bool    b [inline, static]
 

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

Definition at line 251 of file scheduler.h.

References _checkSlaveOnHold().

bool KIO::Scheduler::connect const char *    signal,
const QObject *    receiver,
const char *    member
[inline, static]
 

Function to connect signals emitted by the scheduler.

See also:
slaveConnected , slaveError

Definition at line 231 of file scheduler.h.

void KIO::Scheduler::doJob SimpleJob   job [inline, static]
 

Register job with the scheduler. 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 116 of file scheduler.h.

References _doJob().

virtual QCStringList KIO::Scheduler::functions   [virtual]
 

Returns the list of functions understood by the object. It gets reimplemented by the IDL compiler. If you don't use the IDL compiler, consider implementing this function manually if you want your object to be easily scriptable.

Rationale: functions() allows an interpreter to do client-side type-casting properly.

Note to implementators: remember to call the baseclasses implementation.

Returns:
a list of functions
See also:
interfaces() , process() , processDynamic() , DCOPClient::normalizeFunctionSignature()

Reimplemented from DCOPObject.

KIO::Slave* KIO::Scheduler::getConnectedSlave const KURL   url,
const KIO::MetaData &    config = MetaData()
[inline, static]
 

Requests a slave for use in connection-oriented mode.

Parameters:
url  This defines the username,password,host & port to connect with.
config  Configuration data for the slave.
Returns:
A pointer to a connected slave or 0 if an error occured.
See also:
assignJobToSlave , disconnectSlave

Definition at line 177 of file scheduler.h.

References _getConnectedSlave().

void KIO::Scheduler::jobFinished KIO::SimpleJob   job,
KIO::Slave *    slave
[inline, static]
 

Called when a job is done.

Definition at line 136 of file scheduler.h.

References _jobFinished().

virtual bool KIO::Scheduler::process const QCString &    fun,
const QByteArray &    data,
QCString &    replyType,
QByteArray &    replyData
[virtual]
 

Dispatches a message.

Usually you want to use an IDL compiler to automatically generate an implementation for this function.

If this function returns false, then processDynamic() is called.

Note to implementators: remember to call the baseclasses implementation. It handles the functions "functions()" and "interfaces()" which return the lists of supported functions and interfaces, respectively.

Parameters:
fun  is the normalized function signature. Such a signature usually looks like foobar(QString,int). The return type, qualifiers like "const" etc. are not part of the signature.
data  the received data
replyType  write the reply type in this string
replyData  write the reply data in this array
Returns:
true if successful, false otherwise. The default implementation returns false for all fun except "functions()" and "interfaces()".
See also:
DCOPClient::normalizeFunctionSignature() , functions() , DCOPClient::process()

Reimplemented from DCOPObject.

void KIO::Scheduler::publishSlaveOnHold   [inline, 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.

Definition at line 163 of file scheduler.h.

References _publishSlaveOnHold().

void KIO::Scheduler::putSlaveOnHold KIO::SimpleJob   job,
const KURL   url
[inline, 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. 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 148 of file scheduler.h.

References _putSlaveOnHold().

void KIO::Scheduler::registerWindow QWidget *    wid [inline, static]
 

Register the mainwindow wid with the KIO subsystem Do not call this, it is called automatically from void KIO::Job::setWindow(QWidget *window)

Since:
3.1

Definition at line 221 of file scheduler.h.

References _registerWindow().

void KIO::Scheduler::removeSlaveOnHold   [inline, static]
 

Removes any slave that might have been put on hold. If a slave was put on hold it will be killed.

Definition at line 155 of file scheduler.h.

References _removeSlaveOnHold().

void KIO::Scheduler::scheduleJob SimpleJob   job [inline, static]
 

Calling ths function makes that job gets scheduled for later execution, if multiple jobs are registered it might wait for other jobs to finish.

Definition at line 124 of file scheduler.h.

References _scheduleJob().


The documentation for this class was generated from the following file:
Generated on Wed Aug 13 23:30:33 2003 for kdelibs by doxygen1.2.18