• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdeio
 

tdeio/tdeio

  • TDEIO
  • Scheduler
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | List of all members
TDEIO::Scheduler Class Reference

#include <scheduler.h>

Inherits TQObject, and DCOPObject.

Public Types

typedef TQPtrList< SimpleJob > JobList
 

Public Slots

void slotSlaveDied (TDEIO::Slave *slave)
 
void slotSlaveStatus (pid_t pid, const TQCString &protocol, const TQString &host, bool connected)
 

Signals

void slaveConnected (TDEIO::Slave *slave)
 
void slaveError (TDEIO::Slave *slave, int error, const TQString &errorMsg)
 

Public Member Functions

bool connect (const TQObject *sender, const char *signal, const char *member)
 
void debug_info ()
 
virtual bool process (const TQCString &fun, const TQByteArray &data, TQCString &replyType, TQByteArray &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 (TDEIO::SimpleJob *job, TDEIO::Slave *slave)
 
static void putSlaveOnHold (TDEIO::SimpleJob *job, const KURL &url)
 
static void removeSlaveOnHold ()
 
static void publishSlaveOnHold ()
 
static TDEIO::Slave * getConnectedSlave (const KURL &url, const TDEIO::MetaData &config=MetaData())
 
static bool assignJobToSlave (TDEIO::Slave *slave, TDEIO::SimpleJob *job)
 
static bool disconnectSlave (TDEIO::Slave *slave)
 
static void registerWindow (TQWidget *wid)
 
static void unregisterWindow (TQObject *wid)
 
static bool connect (const char *signal, const TQObject *receiver, const char *member)
 
static bool connect (const TQObject *sender, const char *signal, const TQObject *receiver, const char *member)
 
static bool disconnect (const TQObject *sender, const char *signal, const TQObject *receiver, const char *member)
 
static void checkSlaveOnHold (bool b)
 

Protected Slots

void startStep ()
 
void slotCleanIdleSlaves ()
 
void slotSlaveConnected ()
 
void slotSlaveError (int error, const TQString &errorMsg)
 
void slotScheduleCoSlave ()
 
void slotUnregisterWindow (TQObject *)
 

Protected Member Functions

void setupSlave (TDEIO::Slave *slave, const KURL &url, const TQString &protocol, const TQString &proxy, bool newSlave, const TDEIO::MetaData *config=0)
 
bool startJobScheduled (ProtocolInfo *protInfo)
 
bool startJobDirect ()
 
virtual void virtual_hook (int id, void *data)
 

Detailed Description

The TDEIO::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 TDEIO::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 = TDEIO::get(KURL("http://www.kde.org"));
TDEIO::TransferJob
The transfer job pumps data into and/or out of a Slave.
Definition: jobclasses.h:874
TDEIO::get
TDEIO_EXPORT TransferJob * get(const KURL &url, bool reload=false, bool showProgressInfo=true)
Get (a.k.a.
Definition: job.cpp:1284

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 = TDEIO::get(KURL("http://www.kde.org"));
TDEIO::Scheduler::scheduleJob(job);
TDEIO::Scheduler::scheduleJob
static void scheduleJob(SimpleJob *job)
Definition: scheduler.h:137

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 = TDEIO::Scheduler::getConnectedSlave(
KURL("pop3://bastian:password@mail.kde.org"));
TransferJob *job1 = TDEIO::get(
KURL("pop3://bastian:password@mail.kde.org/msg1"));
TDEIO::Scheduler::assignJobToSlave(slave, job1);
TransferJob *job2 = TDEIO::get(
KURL("pop3://bastian:password@mail.kde.org/msg2"));
TDEIO::Scheduler::assignJobToSlave(slave, job2);
TransferJob *job3 = TDEIO::get(
KURL("pop3://bastian:password@mail.kde.org/msg3"));
TDEIO::Scheduler::assignJobToSlave(slave, job3);
// ... Wait for jobs to finish...
TDEIO::Scheduler::disconnectSlave(slave);
TDEIO::Scheduler::getConnectedSlave
static TDEIO::Slave * getConnectedSlave(const KURL &url, const TDEIO::MetaData &config=MetaData())
Requests a slave for use in connection-oriented mode.
Definition: scheduler.h:195
TDEIO::Slave
Attention developers: If you change the implementation of TDEIO::Slave, do not use connection() or sl...
Definition: slave.h:44

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

if (error == TDEIO::ERR_CONNECTION_BROKEN)
TDEIO::Scheduler::disconnectSlave(slave);
See also
TDEIO::Slave
TDEIO::Job

Definition at line 110 of file scheduler.h.

Member Typedef Documentation

◆ JobList

typedef TQPtrList<SimpleJob> TDEIO::Scheduler::JobList

Definition at line 114 of file scheduler.h.

Constructor & Destructor Documentation

◆ ~Scheduler()

Scheduler::~Scheduler ( )

Definition at line 148 of file scheduler.cpp.

◆ Scheduler()

Scheduler::Scheduler ( )
protected

Definition at line 126 of file scheduler.cpp.

Member Function Documentation

◆ assignJobToSlave()

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

Definition at line 214 of file scheduler.h.

◆ cancelJob()

static void TDEIO::Scheduler::cancelJob ( SimpleJob *  job)
inlinestatic
Stop the execution of a job.
Parameters
jobthe job to cancel

Definition at line 144 of file scheduler.h.

◆ checkSlaveOnHold()

static void TDEIO::Scheduler::checkSlaveOnHold ( bool  b)
inlinestatic
When true, the next job will check whether TDELauncher has a slave 
on hold that is suitable for the job.
Parameters
btrue when TDELauncher has a job on hold

Definition at line 279 of file scheduler.h.

◆ connect() [1/3]

static bool TDEIO::Scheduler::connect ( const char *  signal,
const TQObject *  receiver,
const char *  member 
)
inlinestatic

Function to connect signals emitted by the scheduler.

See also
slaveConnected()
slaveError()

Definition at line 258 of file scheduler.h.

◆ connect() [2/3]

bool TDEIO::Scheduler::connect ( const TQObject *  sender,
const char *  signal,
const char *  member 
)
inline

Definition at line 270 of file scheduler.h.

◆ connect() [3/3]

static bool TDEIO::Scheduler::connect ( const TQObject *  sender,
const char *  signal,
const TQObject *  receiver,
const char *  member 
)
inlinestatic

Definition at line 262 of file scheduler.h.

◆ debug_info()

void Scheduler::debug_info ( )

Definition at line 162 of file scheduler.cpp.

◆ disconnect()

static bool TDEIO::Scheduler::disconnect ( const TQObject *  sender,
const char *  signal,
const TQObject *  receiver,
const char *  member 
)
inlinestatic

Definition at line 266 of file scheduler.h.

◆ disconnectSlave()

static bool TDEIO::Scheduler::disconnectSlave ( TDEIO::Slave *  slave)
inlinestatic

Definition at line 229 of file scheduler.h.

◆ doJob()

static void TDEIO::Scheduler::doJob ( SimpleJob *  job)
inlinestatic
Register @p 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.
Parameters
jobthe job to register

Definition at line 128 of file scheduler.h.

◆ functions()

QCStringList Scheduler::functions ( )
virtual

Definition at line 193 of file scheduler.cpp.

◆ getConnectedSlave()

static TDEIO::Slave * TDEIO::Scheduler::getConnectedSlave ( const KURL &  url,
const TDEIO::MetaData &  config = MetaData() 
)
inlinestatic

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 0 if an error occurred.
See also
assignJobToSlave()
disconnectSlave()

Definition at line 195 of file scheduler.h.

◆ jobFinished()

static void TDEIO::Scheduler::jobFinished ( TDEIO::SimpleJob *  job,
TDEIO::Slave *  slave 
)
inlinestatic
Called when a job is done.
Parameters
jobthe finished job
slavethe slave that executed the job

Definition at line 152 of file scheduler.h.

◆ process()

bool Scheduler::process ( const TQCString &  fun,
const TQByteArray &  data,
TQCString &  replyType,
TQByteArray &  replyData 
)
virtual

Definition at line 166 of file scheduler.cpp.

◆ publishSlaveOnHold()

static void TDEIO::Scheduler::publishSlaveOnHold ( )
inlinestatic

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

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

Definition at line 181 of file scheduler.h.

◆ putSlaveOnHold()

static void TDEIO::Scheduler::putSlaveOnHold ( TDEIO::SimpleJob *  job,
const KURL &  url 
)
inlinestatic
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.
Parameters
jobthe job that should be stopped
urlthe URL that is handled by the url

Definition at line 166 of file scheduler.h.

◆ registerWindow()

static void TDEIO::Scheduler::registerWindow ( TQWidget *  wid)
inlinestatic
Send the slave that was put on hold back to TDELauncher. This
allows another process to take over the slave and resume the job
the that was started.
Register the mainwindow @p wid with the TDEIO subsystem
Do not call this, it is called automatically from
void TDEIO::Job::setWindow(TQWidget*).
Parameters
widthe window to register
Since
3.1

Definition at line 242 of file scheduler.h.

◆ removeSlaveOnHold()

static void TDEIO::Scheduler::removeSlaveOnHold ( )
inlinestatic

Removes any slave that might have been put on hold.

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

Definition at line 173 of file scheduler.h.

◆ scheduleJob()

static void TDEIO::Scheduler::scheduleJob ( SimpleJob *  job)
inlinestatic
Calling ths function makes that @p job gets scheduled for later
execution, if multiple jobs are registered it might wait for
other jobs to finish.
Parameters
jobthe job to schedule

Definition at line 137 of file scheduler.h.

◆ setupSlave()

void Scheduler::setupSlave ( TDEIO::Slave *  slave,
const KURL &  url,
const TQString &  protocol,
const TQString &  proxy,
bool  newSlave,
const TDEIO::MetaData *  config = 0 
)
protected

Definition at line 283 of file scheduler.cpp.

◆ slotCleanIdleSlaves

void Scheduler::slotCleanIdleSlaves ( )
protectedslot

Definition at line 634 of file scheduler.cpp.

◆ slotScheduleCoSlave

void Scheduler::slotScheduleCoSlave ( )
protectedslot

Definition at line 727 of file scheduler.cpp.

◆ slotSlaveConnected

void Scheduler::slotSlaveConnected ( )
protectedslot

Definition at line 770 of file scheduler.cpp.

◆ slotSlaveDied

void Scheduler::slotSlaveDied ( TDEIO::Slave *  slave)
slot

Definition at line 610 of file scheduler.cpp.

◆ slotSlaveError

void Scheduler::slotSlaveError ( int  error,
const TQString &  errorMsg 
)
protectedslot

Definition at line 784 of file scheduler.cpp.

◆ slotSlaveStatus

void Scheduler::slotSlaveStatus ( pid_t  pid,
const TQCString &  protocol,
const TQString &  host,
bool  connected 
)
slot

Definition at line 567 of file scheduler.cpp.

◆ slotUnregisterWindow

void Scheduler::slotUnregisterWindow ( TQObject *  obj)
protectedslot
Since
3.1

Definition at line 900 of file scheduler.cpp.

◆ startJobDirect()

bool Scheduler::startJobDirect ( )
protected

Definition at line 413 of file scheduler.cpp.

◆ startJobScheduled()

bool Scheduler::startJobScheduled ( ProtocolInfo *  protInfo)
protected

Definition at line 331 of file scheduler.cpp.

◆ startStep

void Scheduler::startStep ( )
protectedslot

Definition at line 269 of file scheduler.cpp.

◆ unregisterWindow()

static void TDEIO::Scheduler::unregisterWindow ( TQObject *  wid)
inlinestatic

Definition at line 249 of file scheduler.h.

◆ virtual_hook()

void Scheduler::virtual_hook ( int  id,
void *  data 
)
protectedvirtual

Definition at line 929 of file scheduler.cpp.


The documentation for this class was generated from the following files:
  • scheduler.h
  • scheduler.cpp

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.9.4
This website is maintained by Timothy Pearson.