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

tdeio/tdeio

  • tdeio
  • tdeio
scheduler.h
1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
3 Waldo Bastian <bastian@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#ifndef _tdeio_scheduler_h
22#define _tdeio_scheduler_h
23
24#include "tdeio/job.h"
25#include "tdeio/jobclasses.h"
26#include <tqtimer.h>
27#include <tqptrdict.h>
28#include <tqmap.h>
29
30#include <dcopobject.h>
31
32namespace TDEIO {
33
34 class Slave;
35 class SlaveList;
36 class SlaveConfig;
37 class SessionData;
38
110 class TDEIO_EXPORT Scheduler : public TQObject, virtual public DCOPObject {
111 TQ_OBJECT
112
113 public:
114 typedef TQPtrList<SimpleJob> JobList;
115
116 // InfoDict needs Info, so we can't declare it private
117 class ProtocolInfo;
118 class JobData;
119
120 ~Scheduler();
121
128 static void doJob(SimpleJob *job)
129 { self()->_doJob(job); }
130
137 static void scheduleJob(SimpleJob *job)
138 { self()->_scheduleJob(job); }
139
144 static void cancelJob(SimpleJob *job)
145 { self()->_cancelJob(job); }
146
152 static void jobFinished(TDEIO::SimpleJob *job, TDEIO::Slave *slave)
153 { self()->_jobFinished(job, slave); }
154
166 static void putSlaveOnHold(TDEIO::SimpleJob *job, const KURL &url)
167 { self()->_putSlaveOnHold(job, url); }
168
173 static void removeSlaveOnHold()
174 { self()->_removeSlaveOnHold(); }
175
181 static void publishSlaveOnHold()
182 { self()->_publishSlaveOnHold(); }
183
195 static TDEIO::Slave *getConnectedSlave(const KURL &url, const TDEIO::MetaData &config = MetaData() )
196 { return self()->_getConnectedSlave(url, config); }
197
198 /*
199 * Uses @p slave to do @p job.
200 * This function should be called immediately after creating a Job.
201 *
202 * @param slave The slave to use. The slave must have been obtained
203 * with a call to getConnectedSlave and must not
204 * be currently assigned to any other job.
205 * @param job The job to do.
206 *
207 * @return true is successful, false otherwise.
208 *
209 * @see getConnectedSlave()
210 * @see disconnectSlave()
211 * @see slaveConnected()
212 * @see slaveError()
213 */
214 static bool assignJobToSlave(TDEIO::Slave *slave, TDEIO::SimpleJob *job)
215 { return self()->_assignJobToSlave(slave, job); }
216
217 /*
218 * Disconnects @p slave.
219 *
220 * @param slave The slave to disconnect. The slave must have been
221 * obtained with a call to getConnectedSlave
222 * and must not be assigned to any job.
223 *
224 * @return true is successful, false otherwise.
225 *
226 * @see getConnectedSlave
227 * @see assignJobToSlave
228 */
229 static bool disconnectSlave(TDEIO::Slave *slave)
230 { return self()->_disconnectSlave(slave); }
231
242 static void registerWindow(TQWidget *wid)
243 { self()->_registerWindow(wid); }
244
249 static void unregisterWindow(TQObject *wid)
250 { self()->slotUnregisterWindow(wid); }
251
258 static bool connect( const char *signal, const TQObject *receiver,
259 const char *member)
260 { return TQObject::connect(self(), signal, receiver, member); }
261
262 static bool connect( const TQObject* sender, const char* signal,
263 const TQObject* receiver, const char* member )
264 { return TQObject::connect(sender, signal, receiver, member); }
265
266 static bool disconnect( const TQObject* sender, const char* signal,
267 const TQObject* receiver, const char* member )
268 { return TQObject::disconnect(sender, signal, receiver, member); }
269
270 bool connect( const TQObject *sender, const char *signal,
271 const char *member )
272 { return TQObject::connect(sender, signal, member); }
273
279 static void checkSlaveOnHold(bool b) { self()->_checkSlaveOnHold(b); }
280
281 void debug_info();
282
283 virtual bool process(const TQCString &fun, const TQByteArray &data,
284 TQCString& replyType, TQByteArray &replyData);
285
286 virtual QCStringList functions();
287
288 public slots:
289 void slotSlaveDied(TDEIO::Slave *slave);
290 void slotSlaveStatus(pid_t pid, const TQCString &protocol,
291 const TQString &host, bool connected);
292 signals:
293 void slaveConnected(TDEIO::Slave *slave);
294 void slaveError(TDEIO::Slave *slave, int error, const TQString &errorMsg);
295
296 protected:
297 void setupSlave(TDEIO::Slave *slave, const KURL &url, const TQString &protocol, const TQString &proxy , bool newSlave, const TDEIO::MetaData *config=0);
298 bool startJobScheduled(ProtocolInfo *protInfo);
299 bool startJobDirect();
300 Scheduler();
301
302 protected slots:
303 void startStep();
304 void slotCleanIdleSlaves();
305 void slotSlaveConnected();
306 void slotSlaveError(int error, const TQString &errorMsg);
307 void slotScheduleCoSlave();
309 void slotUnregisterWindow(TQObject *);
310
311 private:
312 class ProtocolInfoDict;
313 class ExtraJobData;
314
315 Scheduler(const Scheduler&);
316 static Scheduler *self();
317 static Scheduler *instance;
318 void _doJob(SimpleJob *job);
319 void _scheduleJob(SimpleJob *job);
320 void _cancelJob(SimpleJob *job);
321 void _jobFinished(TDEIO::SimpleJob *job, TDEIO::Slave *slave);
322 void _scheduleCleanup();
323 void _putSlaveOnHold(TDEIO::SimpleJob *job, const KURL &url);
324 void _removeSlaveOnHold();
325 Slave *_getConnectedSlave(const KURL &url, const TDEIO::MetaData &metaData );
326 bool _assignJobToSlave(TDEIO::Slave *slave, TDEIO::SimpleJob *job);
327 bool _disconnectSlave(TDEIO::Slave *slave);
328 void _checkSlaveOnHold(bool b);
329 void _publishSlaveOnHold();
330 void _registerWindow(TQWidget *wid);
331
332 Slave *findIdleSlave(ProtocolInfo *protInfo, SimpleJob *job, bool &exact);
333 Slave *createSlave(ProtocolInfo *protInfo, SimpleJob *job, const KURL &url);
334
335
336 TQTimer slaveTimer;
337 TQTimer coSlaveTimer;
338 TQTimer cleanupTimer;
339 bool busy;
340
341 SlaveList *slaveList;
342 SlaveList *idleSlaves;
343 SlaveList *coIdleSlaves;
344
345 ProtocolInfoDict *protInfoDict;
346 Slave *slaveOnHold;
347 KURL urlOnHold;
348 JobList newJobs;
349
350 TQPtrDict<JobList> coSlaves;
351 ExtraJobData *extraJobData;
352 SlaveConfig *slaveConfig;
353 SessionData *sessionData;
354 bool checkOnHold;
355 TQMap<TQObject *,WId> m_windowList;
356 protected:
357 virtual void virtual_hook( int id, void* data );
358 private:
359 class SchedulerPrivate* d;
360};
361
362}
363#endif
TDEIO::MetaData
MetaData is a simple map of key/value strings.
Definition global.h:516
TDEIO::Scheduler
The TDEIO::Scheduler manages io-slaves for the application.
Definition scheduler.h:110
TDEIO::Scheduler::publishSlaveOnHold
static void publishSlaveOnHold()
Send the slave that was put on hold back to TDELauncher.
Definition scheduler.h:181
TDEIO::Scheduler::scheduleJob
static void scheduleJob(SimpleJob *job)
Definition scheduler.h:137
TDEIO::Scheduler::connect
static bool connect(const char *signal, const TQObject *receiver, const char *member)
Function to connect signals emitted by the scheduler.
Definition scheduler.h:258
TDEIO::Scheduler::registerWindow
static void registerWindow(TQWidget *wid)
Definition scheduler.h:242
TDEIO::Scheduler::putSlaveOnHold
static void putSlaveOnHold(TDEIO::SimpleJob *job, const KURL &url)
Definition scheduler.h:166
TDEIO::Scheduler::removeSlaveOnHold
static void removeSlaveOnHold()
Removes any slave that might have been put on hold.
Definition scheduler.h:173
TDEIO::Scheduler::cancelJob
static void cancelJob(SimpleJob *job)
Definition scheduler.h:144
TDEIO::Scheduler::jobFinished
static void jobFinished(TDEIO::SimpleJob *job, TDEIO::Slave *slave)
Definition scheduler.h:152
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::Scheduler::doJob
static void doJob(SimpleJob *job)
Definition scheduler.h:128
TDEIO::Scheduler::checkSlaveOnHold
static void checkSlaveOnHold(bool b)
Definition scheduler.h:279
TDEIO::SimpleJob
A simple job (one url and one command).
Definition jobclasses.h:527
TDEIO::SlaveConfig
SlaveConfig.
Definition slaveconfig.h:47
TDEIO::Slave
Attention developers: If you change the implementation of TDEIO::Slave, do not use connection() or sl...
Definition slave.h:44
TDEIO
A namespace for TDEIO globals.
Definition authinfo.h:29

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • Main Page
  • 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.8
This website is maintained by Timothy Pearson.