\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=89pt]{classKIO_1_1Scheduler__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KIO::Scheduler:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=243pt]{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 
void {\bf do\-Job} ({\bf Simple\-Job} $\ast$job)
\begin{CompactList}\small\item\em Register {\tt job} with the scheduler. \item\end{CompactList}\item 
void {\bf schedule\-Job} ({\bf Simple\-Job} $\ast$job)
\begin{CompactList}\small\item\em 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. \item\end{CompactList}\item 
void {\bf cancel\-Job} ({\bf Simple\-Job} $\ast$job)
\begin{CompactList}\small\item\em Stop the execution of a job. \item\end{CompactList}\item 
void {\bf job\-Finished} ({\bf KIO::Simple\-Job} $\ast$job, KIO::Slave $\ast$slave)
\begin{CompactList}\small\item\em Called when a job is done. \item\end{CompactList}\item 
void {\bf put\-Slave\-On\-Hold} ({\bf KIO::Simple\-Job} $\ast$job, const  {\bf KURL} \&url)
\begin{CompactList}\small\item\em Puts a slave on notice. \item\end{CompactList}\item 
void {\bf remove\-Slave\-On\-Hold} ()
\begin{CompactList}\small\item\em Removes any slave that might have been put on hold. \item\end{CompactList}\item 
void {\bf publish\-Slave\-On\-Hold} ()
\begin{CompactList}\small\item\em Send the slave that was put on hold back to KLauncher. \item\end{CompactList}\item 
KIO::Slave $\ast$ {\bf get\-Connected\-Slave} (const  {\bf KURL} \&url, const  KIO::Meta\-Data \&config=Meta\-Data())
\begin{CompactList}\small\item\em Requests a slave for use in connection-oriented mode. \item\end{CompactList}\item 
bool {\bf assign\-Job\-To\-Slave} (KIO::Slave $\ast$slave, {\bf KIO::Simple\-Job} $\ast$job)\label{classKIO_1_1Scheduler_e8}

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

\item 
void {\bf register\-Window} ({\bf QWidget} $\ast$wid)
\begin{CompactList}\small\item\em 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$window)}{\rm (p.\,\pageref{classKIO_1_1Job_a10})} \begin{Desc}
\item[Since:]3.1. \end{Desc}
\item\end{CompactList}\item 
bool {\bf connect} (const  char $\ast$signal, const  {\bf QObject} $\ast$receiver, const  char $\ast$member)
\begin{CompactList}\small\item\em Function to connect signals emitted by the scheduler. \item\end{CompactList}\item 
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_e12}

\item 
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_e13}

\item 
void {\bf check\-Slave\-On\-Hold} (bool b)
\begin{CompactList}\small\item\em When true, the next job will check whether KLauncher has a slave on hold that is suitable for the job. \item\end{CompactList}\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$)
\begin{CompactList}\small\item\em \begin{Desc}
\item[Since:]3.1 \end{Desc}
\item\end{CompactList}\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  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:

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: {\bf Transfer\-Job}{\rm (p.\,\pageref{classKIO_1_1TransferJob})} $\ast$job = {\bf KIO::get}{\rm (p.\,\pageref{namespaceKIO_a205})}({\bf KURL}(\char`\"{}http://www.kde.org\char`\"{}));

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: \small\begin{alltt}
    {\bf TransferJob}{\rm (p.\,\pageref{classKIO_1_1TransferJob})} *job = {\bf KIO::get}{\rm (p.\,\pageref{namespaceKIO_a205})}({\bf KURL}("http://www.kde.org"));
    KIO::Scheduler::scheduleJob(job);
 \end{alltt}\normalsize 


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: \small\begin{alltt}
    Slave *slave = {\bf KIO::Scheduler::getConnectedSlave}{\rm (p.\,\pageref{classKIO_1_1Scheduler_e7})}(
            {\bf KURL}("pop3://bastian:password@mail.kde.org"));
    {\bf TransferJob}{\rm (p.\,\pageref{classKIO_1_1TransferJob})} *job1 = {\bf KIO::get}{\rm (p.\,\pageref{namespaceKIO_a205})}(
            {\bf KURL}("pop3://bastian:password@mail.kde.org/msg1"));
    KIO::Scheduler::assignJobToSlave(slave, job1);
    {\bf TransferJob}{\rm (p.\,\pageref{classKIO_1_1TransferJob})} *job2 = {\bf KIO::get}{\rm (p.\,\pageref{namespaceKIO_a205})}(
            {\bf KURL}("pop3://bastian:password@mail.kde.org/msg2"));
    KIO::Scheduler::assignJobToSlave(slave, job2);
    {\bf TransferJob}{\rm (p.\,\pageref{classKIO_1_1TransferJob})} *job3 = {\bf KIO::get}{\rm (p.\,\pageref{namespaceKIO_a205})}(
            {\bf KURL}("pop3://bastian:password@mail.kde.org/msg3"));
    KIO::Scheduler::assignJobToSlave(slave, job3);\end{alltt}\normalsize 


\small\begin{alltt}    // ... Wait for jobs to finish...\end{alltt}\normalsize 


\small\begin{alltt}    KIO::Scheduler::disconnectSlave(slave);
 \end{alltt}\normalsize 
 



Definition at line 99 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}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 {\bf schedule\-Job}{\rm (p.\,\pageref{classKIO_1_1Scheduler_e1})}. 

Definition at line 116 of file scheduler.h.

References \_\-do\-Job().\index{KIO::Scheduler@{KIO::Scheduler}!scheduleJob@{scheduleJob}}
\index{scheduleJob@{scheduleJob}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}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. 



Definition at line 124 of file scheduler.h.

References \_\-schedule\-Job().\index{KIO::Scheduler@{KIO::Scheduler}!cancelJob@{cancelJob}}
\index{cancelJob@{cancelJob}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}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. 



Definition at line 130 of file scheduler.h.

References \_\-cancel\-Job().\index{KIO::Scheduler@{KIO::Scheduler}!jobFinished@{jobFinished}}
\index{jobFinished@{jobFinished}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}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. 



Definition at line 136 of file scheduler.h.

References \_\-job\-Finished().\index{KIO::Scheduler@{KIO::Scheduler}!putSlaveOnHold@{putSlaveOnHold}}
\index{putSlaveOnHold@{putSlaveOnHold}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}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. 

Definition at line 148 of file scheduler.h.

References \_\-put\-Slave\-On\-Hold().\index{KIO::Scheduler@{KIO::Scheduler}!removeSlaveOnHold@{removeSlaveOnHold}}
\index{removeSlaveOnHold@{removeSlaveOnHold}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}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 155 of file scheduler.h.

References \_\-remove\-Slave\-On\-Hold().\index{KIO::Scheduler@{KIO::Scheduler}!publishSlaveOnHold@{publishSlaveOnHold}}
\index{publishSlaveOnHold@{publishSlaveOnHold}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}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 163 of file scheduler.h.

References \_\-publish\-Slave\-On\-Hold().

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}KIO::Slave$\ast$ KIO::Scheduler::get\-Connected\-Slave (const {\bf KURL} \& {\em url}, const KIO::Meta\-Data \& {\em config} = 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 occured. \end{Desc}
\begin{Desc}
\item[See also:]assign\-Job\-To\-Slave 

disconnect\-Slave \end{Desc}


Definition at line 177 of file scheduler.h.

References \_\-get\-Connected\-Slave().\index{KIO::Scheduler@{KIO::Scheduler}!registerWindow@{registerWindow}}
\index{registerWindow@{registerWindow}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KIO::Scheduler::register\-Window ({\bf QWidget} $\ast$ {\em wid})\hspace{0.3cm}{\tt  [inline, static]}}\label{classKIO_1_1Scheduler_e10}


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$window)}{\rm (p.\,\pageref{classKIO_1_1Job_a10})} \begin{Desc}
\item[Since:]3.1. \end{Desc}




Definition at line 221 of file scheduler.h.

References \_\-register\-Window().\index{KIO::Scheduler@{KIO::Scheduler}!connect@{connect}}
\index{connect@{connect}!KIO::Scheduler@{KIO::Scheduler}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}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_e11}


Function to connect signals emitted by the scheduler. 

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

slave\-Error \end{Desc}


Definition at line 231 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}void KIO::Scheduler::check\-Slave\-On\-Hold (bool {\em b})\hspace{0.3cm}{\tt  [inline, static]}}\label{classKIO_1_1Scheduler_e14}


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 \_\-check\-Slave\-On\-Hold().\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 878 of file scheduler.cpp.

References QMap$<$ QObject $\ast$, long $>$::end(), and QMap$<$ QObject $\ast$, long $>$::find().

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