27 #include <tqptrlist.h>
29 #include <tqwaitcondition.h>
33 #include <kdepimmacros.h>
36 namespace ThreadWeaver {
54 KDE_EXPORT extern bool Debug;
55 KDE_EXPORT extern int DebugLevel;
57 KDE_EXPORT inline void setDebugLevel ( bool debug, int level)
63 KDE_EXPORT inline void debug( int severity, const char * cformat, ...)
65 __attribute__ ( (format (printf, 2, 3 ) ) )
69 KDE_EXPORT inline void debug( int severity, const char * cformat, ...)
71 if ( Debug == true && ( severity<=DebugLevel || severity == 0) )
78 va_start( ap, cformat );
79 vprintf (cformat, ap);
100 class KDE_EXPORT Event : public TQCustomEvent
124 Action action () const;
129 static const int Type;
164 class KDE_EXPORT Job : public TQObject
170 Job(TQObject* parent=0, const char* name=0);
179 virtual void execute( Thread*);
182 virtual bool isFinished() const;
189 virtual void processEvent ( Event* );
220 virtual void run () = 0;
225 virtual void setFinished( bool status);
243 TQWaitCondition *m_wc;
250 class KDE_EXPORT Thread : public TQThread
274 void msleep( unsigned long msec);
280 unsigned int id() const;
288 const unsigned int m_id;
290 static unsigned int sm_Id;
292 static unsigned int makeId();
297 class KDE_EXPORT Weaver : public TQObject
302 Weaver (TQObject* parent=0, const char* name=0,
303 int inventoryMin = 4,
304 int inventoryMax = 32);
307 virtual void enqueue ( Job*);
316 void enqueue (TQPtrList<Job> jobs);
326 virtual bool dequeue ( Job*);
330 virtual void dequeue ();
341 virtual void finish();
352 virtual void suspend ( bool state);
354 bool isEmpty () const;
358 bool isIdle () const;
371 virtual Job* applyForWork ( Thread *thread, Job *previous);
384 int threads () const;
403 void threadCreated ( Thread *);
404 void threadDestroyed ( Thread *);
405 void threadBusy ( Thread *);
406 void threadSuspended ( Thread *);
415 bool event ( TQEvent* );
451 #endif // defined WEAVER_H
|