27 #include <tqptrlist.h> 29 #include <tqwaitcondition.h> 33 #include <tdepimmacros.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 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 TQPtrList< Job > m_assignments The job queue.
A class to represent the events threads generate and send to the Weaver object.
A weaver is the manager of worker threads (Thread objects) to which it assigns jobs from it's queue...
All jobs in the queue are done.
TQPtrList< Thread > m_inventory The thread inventory.
bool m_shuttingDown Indicates if the weaver is shutting down and exiting it's threads.
int m_inventoryMin Stored setting.
TQWaitCondition m_jobFinished Wait for a job to finish.
TDEPIM classes for drag and drop of mails.
TQWaitCondition m_jobAvailable Wait condition all idle or done threads wait for.
int m_inventoryMax Stored setting .
The class Thread is used to represent the worker threads in the weaver's inventory.
A Job is a simple abstraction of an action that is to be executed in a thread context.
int m_active The number of jobs that are assigned to the worker threads, but not finished.
bool m_suspend If m_suspend is true, no new jobs will be assigned to threads.
bool m_running m_running is set to true when a job is enqueued and set to false when the job finishes that was the l...
|