26 #include <tqptrlist.h> 28 #include <tqwaitcondition.h> 32 #include <tdepimmacros.h> 35 namespace ThreadWeaver { 53 KDE_EXPORT extern bool Debug; 54 KDE_EXPORT extern int DebugLevel; 56 KDE_EXPORT inline void setDebugLevel ( bool debug, int level) 62 KDE_EXPORT inline void debug( int severity, const char * cformat, ...) 64 __attribute__ ( (format (printf, 2, 3 ) ) ) 68 KDE_EXPORT inline void debug( int severity, const char * cformat, ...) 70 if ( Debug == true && ( severity<=DebugLevel || severity == 0) ) 77 va_start( ap, cformat ); 78 vprintf (cformat, ap); 99 class KDE_EXPORT Event : public TQCustomEvent 128 static const int Type; 163 class KDE_EXPORT Job : public TQObject 169 Job(TQObject* parent=0, const char* name=0); 178 virtual void execute( Thread*); 181 virtual bool isFinished() const; 188 virtual void processEvent ( Event* ); 219 virtual void run () = 0; 224 virtual void setFinished( bool status); 242 TQWaitCondition *m_wc; 249 class KDE_EXPORT Thread : public TQThread 273 void msleep( unsigned long msec); 279 unsigned int id() const; 287 const unsigned int m_id; 289 static unsigned int sm_Id; 291 static unsigned int makeId(); 296 class KDE_EXPORT Weaver : public TQObject 301 Weaver (TQObject* parent=0, const char* name=0, 302 int inventoryMin = 4, 303 int inventoryMax = 32); 306 virtual void enqueue ( Job*); 315 void enqueue (TQPtrList<Job> jobs); 325 virtual bool dequeue ( Job*); 329 virtual void dequeue (); 340 virtual void finish(); 351 virtual void suspend ( bool state); 353 bool isEmpty () const; 357 bool isIdle () const; 370 virtual Job* applyForWork ( Thread *thread, Job *previous); 383 int threads () const; 402 void threadCreated ( Thread *); 403 void threadDestroyed ( Thread *); 404 void threadBusy ( Thread *); 405 void threadSuspended ( Thread *); 414 bool event ( TQEvent* ); 450 #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...
|