\section{KIO::Scheduler Class Reference}
\label{classKIO_1_1Scheduler}\index{KIO::Scheduler@{KIO::Scheduler}}
The KIO::Scheduler manages io-slaves for the application.  


{\tt \#include $<$scheduler.h$>$}

Inheritance diagram for KIO::Scheduler:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=90pt]{classKIO_1_1Scheduler__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KIO::Scheduler:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=219pt]{classKIO_1_1Scheduler__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Types}
\begin{CompactItemize}
\item 
typedef {\bf QPtr\-List}$<$ {\bf Simple\-Job} $>$ {\bf Job\-List}\label{classKIO_1_1Scheduler_w0}

\end{CompactItemize}
\subsection*{Public Slots}
\begin{CompactItemize}
\item 
void {\bf slot\-Slave\-Died} (KIO::Slave $\ast$slave)\label{classKIO_1_1Scheduler_i0}

\item 
void {\bf slot\-Slave\-Status} (pid\_\-t pid, const {\bf QCString} \&protocol, const {\bf QString} \&host, bool connected)\label{classKIO_1_1Scheduler_i1}

\end{CompactItemize}
\subsection*{Signals}
\begin{CompactItemize}
\item 
void {\bf slave\-Connected} (KIO::Slave $\ast$slave)\label{classKIO_1_1Scheduler_l0}

\item 
void {\bf slave\-Error} (KIO::Slave $\ast$slave, int error, const {\bf QString} \&error\-Msg)\label{classKIO_1_1Scheduler_l1}

\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
bool {\bf connect} (const {\bf QObject} $\ast${\bf sender}, const char $\ast$signal, const char $\ast$member)\label{classKIO_1_1Scheduler_a1}

\item 
void {\bf debug\_\-info} ()\label{classKIO_1_1Scheduler_a2}

\item 
virtual bool {\bf process} (const {\bf QCString} \&fun, const {\bf QByte\-Array} \&data, {\bf QCString} \&reply\-Type, {\bf QByte\-Array} \&reply\-Data)\label{classKIO_1_1Scheduler_a3}

\item 
virtual QCString\-List {\bf functions} ()\label{classKIO_1_1Scheduler_a4}

\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
static void {\bf do\-Job} ({\bf Simple\-Job} $\ast$job)
\item 
static void {\bf schedule\-Job} ({\bf Simple\-Job} $\ast$job)
\item 
static void {\bf cancel\-Job} ({\bf Simple\-Job} $\ast$job)
\item 
static void {\bf job\-Finished} ({\bf KIO::Simple\-Job} $\ast$job, KIO::Slave $\ast$slave)
\item 
static void {\bf put\-Slave\-On\-Hold} ({\bf KIO::Simple\-Job} $\ast$job, const {\bf KURL} \&url)
\item 
static void {\bf remove\-Slave\-On\-Hold} ()
\item 
static void {\bf publish\-Slave\-On\-Hold} ()
\item 
static KIO::Slave $\ast$ {\bf get\-Connected\-Slave} (const {\bf KURL} \&url, const {\bf KIO::Meta\-Data} \&config={\bf Meta\-Data}())
\item 
static bool {\bf assign\-Job\-To\-Slave} (KIO::Slave $\ast$slave, {\bf KIO::Simple\-Job} $\ast$job)\label{classKIO_1_1Scheduler_e8}

\item 
static bool {\bf disconnect\-Slave} (KIO::Slave $\ast$slave)\label{classKIO_1_1Scheduler_e9}

\item 
static void {\bf register\-Window} ({\bf QWidget} $\ast$wid)
\item 
static void {\bf unregister\-Window} ({\bf QObject} $\ast$wid)\label{classKIO_1_1Scheduler_e11}

\item 
static bool {\bf connect} (const char $\ast$signal, const {\bf QObject} $\ast$receiver, const char $\ast$member)
\item 
static bool {\bf connect} (const {\bf QObject} $\ast${\bf sender}, const char $\ast$signal, const {\bf QObject} $\ast$receiver, const char $\ast$member)\label{classKIO_1_1Scheduler_e13}

\item 
static bool {\bf disconnect} (const {\bf QObject} $\ast${\bf sender}, const char $\ast$signal, const {\bf QObject} $\ast$receiver, const char $\ast$member)\label{classKIO_1_1Scheduler_e14}

\item 
static void {\bf check\-Slave\-On\-Hold} (bool b)
\end{CompactItemize}
\subsection*{Protected Slots}
\begin{CompactItemize}
\item 
void {\bf start\-Step} ()\label{classKIO_1_1Scheduler_j0}

\item 
void {\bf slot\-Clean\-Idle\-Slaves} ()\label{classKIO_1_1Scheduler_j1}

\item 
void {\bf slot\-Slave\-Connected} ()\label{classKIO_1_1Scheduler_j2}

\item 
void {\bf slot\-Slave\-Error} (int error, const {\bf QString} \&error\-Msg)\label{classKIO_1_1Scheduler_j3}

\item 
void {\bf slot\-Schedule\-Co\-Slave} ()\label{classKIO_1_1Scheduler_j4}

\item 
void {\bf slot\-Unregister\-Window} ({\bf QObject} $\ast$)
\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
void {\bf setup\-Slave} (KIO::Slave $\ast$slave, const {\bf KURL} \&url, const {\bf QString} \&protocol, const {\bf QString} \&proxy, bool new\-Slave, const {\bf KIO::Meta\-Data} $\ast$config=0)\label{classKIO_1_1Scheduler_b0}

\item 
bool {\bf start\-Job\-Scheduled} (Protocol\-Info $\ast$prot\-Info)\label{classKIO_1_1Scheduler_b1}

\item 
bool {\bf start\-Job\-Direct} ()\label{classKIO_1_1Scheduler_b2}

\item 
virtual void {\bf virtual\_\-hook} (int id, void $\ast$data)\label{classKIO_1_1Scheduler_b4}

\end{CompactItemize}


\subsection{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:

\paragraph*{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: 

\footnotesize\begin{verbatim}    TransferJob *job = KIO::get(KURL("http://www.kde.org"));
\end{verbatim}
\normalsize


\paragraph*{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: 

\footnotesize\begin{verbatim}    TransferJob *job = KIO::get(KURL("http://www.kde.org"));
    KIO::Scheduler::scheduleJob(job);
\end{verbatim}
\normalsize


\paragraph*{3. {\bf Connection}{\rm (p.\,\pageref{classKIO_1_1Connection})} 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: 

\footnotesize\begin{verbatim}    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);
\end{verbatim}
\normalsize


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

\footnotesize\begin{verbatim}    if (error == KIO::ERR_CONNECTION_BROKEN)
        KIO::Scheduler::disconnectSlave(slave);
\end{verbatim}
\normalsize


\begin{Desc}
\item[See also:]KIO::Slave 

{\bf KIO::Job}{\rm (p.\,\pageref{classKIO_1_1Job})} \end{Desc}




Definition at line 111 of file scheduler.h.

\subsection{Member Function Documentation}
\index{KIO::Scheduler@{KIO::Scheduler}!doJob@{doJob}}
\index{doJob@{doJob}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static void KIO::Scheduler::do\-Job ({\bf Simple\-Job} $\ast$ {\em job})\hspace{0.3cm}{\tt  [inline, static]}}\label{classKIO_1_1Scheduler_e0}


Register {\tt 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 schedule\-Job. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em job}]the job to register \end{description}
\end{Desc}


Definition at line 129 of file scheduler.h.

Referenced by KIO::Simple\-Job::Simple\-Job(), KIO::Multi\-Get\-Job::slot\-Finished(), KIO::List\-Job::slot\-Finished(), KIO::Mimetype\-Job::slot\-Finished(), KIO::Transfer\-Job::slot\-Finished(), KIO::Stat\-Job::slot\-Finished(), and KIO::Mkdir\-Job::slot\-Finished().\index{KIO::Scheduler@{KIO::Scheduler}!scheduleJob@{scheduleJob}}
\index{scheduleJob@{scheduleJob}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static void KIO::Scheduler::schedule\-Job ({\bf Simple\-Job} $\ast$ {\em job})\hspace{0.3cm}{\tt  [inline, static]}}\label{classKIO_1_1Scheduler_e1}


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

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em job}]the job to schedule \end{description}
\end{Desc}


Definition at line 138 of file scheduler.h.

Referenced by KIO::http\_\-update\_\-cache(), and KIO::Delete\-Job::slot\-Result().\index{KIO::Scheduler@{KIO::Scheduler}!cancelJob@{cancelJob}}
\index{cancelJob@{cancelJob}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static void KIO::Scheduler::cancel\-Job ({\bf Simple\-Job} $\ast$ {\em job})\hspace{0.3cm}{\tt  [inline, static]}}\label{classKIO_1_1Scheduler_e2}


Stop the execution of a job. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em job}]the job to cancel \end{description}
\end{Desc}


Definition at line 145 of file scheduler.h.

Referenced by KIO::Simple\-Job::kill().\index{KIO::Scheduler@{KIO::Scheduler}!jobFinished@{jobFinished}}
\index{jobFinished@{jobFinished}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static void KIO::Scheduler::job\-Finished ({\bf KIO::Simple\-Job} $\ast$ {\em job}, KIO::Slave $\ast$ {\em slave})\hspace{0.3cm}{\tt  [inline, static]}}\label{classKIO_1_1Scheduler_e3}


Called when a job is done. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em job}]the finished job \item[{\em slave}]the slave that executed the {\tt job} \end{description}
\end{Desc}


Definition at line 153 of file scheduler.h.\index{KIO::Scheduler@{KIO::Scheduler}!putSlaveOnHold@{putSlaveOnHold}}
\index{putSlaveOnHold@{putSlaveOnHold}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static void KIO::Scheduler::put\-Slave\-On\-Hold ({\bf KIO::Simple\-Job} $\ast$ {\em job}, const {\bf KURL} \& {\em url})\hspace{0.3cm}{\tt  [inline, static]}}\label{classKIO_1_1Scheduler_e4}


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. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em job}]the job that should be stopped \item[{\em url}]the URL that is handled by the {\tt url} \end{description}
\end{Desc}


Definition at line 167 of file scheduler.h.

Referenced by KIO::Simple\-Job::put\-On\-Hold().\index{KIO::Scheduler@{KIO::Scheduler}!removeSlaveOnHold@{removeSlaveOnHold}}
\index{removeSlaveOnHold@{removeSlaveOnHold}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static void KIO::Scheduler::remove\-Slave\-On\-Hold ()\hspace{0.3cm}{\tt  [inline, static]}}\label{classKIO_1_1Scheduler_e5}


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::Simple\-Job::remove\-On\-Hold().\index{KIO::Scheduler@{KIO::Scheduler}!publishSlaveOnHold@{publishSlaveOnHold}}
\index{publishSlaveOnHold@{publishSlaveOnHold}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static void KIO::Scheduler::publish\-Slave\-On\-Hold ()\hspace{0.3cm}{\tt  [inline, static]}}\label{classKIO_1_1Scheduler_e6}


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::found\-Mime\-Type().\index{KIO::Scheduler@{KIO::Scheduler}!getConnectedSlave@{getConnectedSlave}}
\index{getConnectedSlave@{getConnectedSlave}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static KIO::Slave$\ast$ KIO::Scheduler::get\-Connected\-Slave (const {\bf KURL} \& {\em url}, const {\bf KIO::Meta\-Data} \& {\em config} = {\tt {\bf Meta\-Data}()})\hspace{0.3cm}{\tt  [inline, static]}}\label{classKIO_1_1Scheduler_e7}


Requests a slave for use in connection-oriented mode. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em url}]This defines the username,password,host \& port to connect with. \item[{\em config}]Configuration data for the slave.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A pointer to a connected slave or 0 if an error occurred. \end{Desc}
\begin{Desc}
\item[See also:]assign\-Job\-To\-Slave() 

disconnect\-Slave() \end{Desc}


Definition at line 196 of file scheduler.h.\index{KIO::Scheduler@{KIO::Scheduler}!registerWindow@{registerWindow}}
\index{registerWindow@{registerWindow}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static void KIO::Scheduler::register\-Window ({\bf QWidget} $\ast$ {\em wid})\hspace{0.3cm}{\tt  [inline, static]}}\label{classKIO_1_1Scheduler_e10}


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 {\tt wid} with the {\bf KIO}{\rm (p.\,\pageref{namespaceKIO})} subsystem Do not call this, it is called automatically from void {\bf KIO::Job::set\-Window(QWidget$\ast$)}{\rm (p.\,\pageref{classKIO_1_1Job_a12})}. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em wid}]the window to register \end{description}
\end{Desc}
\begin{Desc}
\item[Since:]3.1 \end{Desc}


Definition at line 243 of file scheduler.h.\index{KIO::Scheduler@{KIO::Scheduler}!connect@{connect}}
\index{connect@{connect}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static bool KIO::Scheduler::connect (const char $\ast$ {\em signal}, const {\bf QObject} $\ast$ {\em receiver}, const char $\ast$ {\em member})\hspace{0.3cm}{\tt  [inline, static]}}\label{classKIO_1_1Scheduler_e12}


Function to connect signals emitted by the scheduler. 

\begin{Desc}
\item[See also:]slave\-Connected() 

slave\-Error() \end{Desc}


Definition at line 259 of file scheduler.h.

References QObject::connect().\index{KIO::Scheduler@{KIO::Scheduler}!checkSlaveOnHold@{checkSlaveOnHold}}
\index{checkSlaveOnHold@{checkSlaveOnHold}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static void KIO::Scheduler::check\-Slave\-On\-Hold (bool {\em b})\hspace{0.3cm}{\tt  [inline, static]}}\label{classKIO_1_1Scheduler_e15}


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

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em b}]true when KLauncher has a job on hold \end{description}
\end{Desc}


Definition at line 280 of file scheduler.h.\index{KIO::Scheduler@{KIO::Scheduler}!slotUnregisterWindow@{slotUnregisterWindow}}
\index{slotUnregisterWindow@{slotUnregisterWindow}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Scheduler::slot\-Unregister\-Window ({\bf QObject} $\ast$)\hspace{0.3cm}{\tt  [protected, slot]}}\label{classKIO_1_1Scheduler_j5}


\begin{Desc}
\item[Since:]3.1 \end{Desc}




Definition at line 887 of file scheduler.cpp.

References QObject::destroyed(), QObject::disconnect(), QMap::end(), QMap::find(), and QMap::remove().

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
scheduler.h\item 
scheduler.cpp\end{CompactItemize}
