|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TTHREADP_H
|
|
Toshihiro Shimizu |
890ddd |
#define TTHREADP_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qobject></qobject>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tthreadmessage.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=====================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//======================================
|
|
Toshihiro Shimizu |
890ddd |
// TThreadMessageDispatcher class
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//NOTE: This class should eventually be moved to tthreadmessagep.h...
|
|
Toshihiro Shimizu |
890ddd |
class TThreadMessageDispatcher : public QObject //singleton
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TThreadMessageDispatcher();
|
|
Toshihiro Shimizu |
890ddd |
Q_SIGNALS : void signaled(TThread::Message *msg);
|
|
Toshihiro Shimizu |
890ddd |
void blockingSignaled(TThread::Message *msg);
|
|
Toshihiro Shimizu |
890ddd |
protected Q_SLOTS:
|
|
Toshihiro Shimizu |
890ddd |
void onSignal(TThread::Message *msg);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
void emitSignaled(TThread::Message *msg);
|
|
Toshihiro Shimizu |
890ddd |
void emitBlockingSignaled(TThread::Message *msg);
|
|
Toshihiro Shimizu |
890ddd |
static void init();
|
|
Toshihiro Shimizu |
890ddd |
static TThreadMessageDispatcher *instance();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=====================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace TThread
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//Forward declarations
|
|
Toshihiro Shimizu |
890ddd |
class ExecutorId;
|
|
Toshihiro Shimizu |
890ddd |
class ExecutorImpSlots;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=====================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================
|
|
Toshihiro Shimizu |
890ddd |
// ExecutorImpSlots class
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TThread::ExecutorImpSlots : public QObject
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
ExecutorImpSlots();
|
|
Toshihiro Shimizu |
890ddd |
~ExecutorImpSlots();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//The following is provided to ensure that point #3 in Qt reference in page "Thread support in Qt"
|
|
Toshihiro Shimizu |
890ddd |
//is satisfied:
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// "You must ensure that all objects created in
|
|
Toshihiro Shimizu |
890ddd |
// a thread are deleted before you delete the QThread."
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//So, specifically, thread creation should happen only in the main thread, not in worker threads.
|
|
Toshihiro Shimizu |
890ddd |
void emitRefreshAssignments();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Q_SIGNALS : void refreshAssignments();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public Q_SLOTS:
|
|
Toshihiro Shimizu |
890ddd |
void onTerminated();
|
|
Toshihiro Shimizu |
890ddd |
void onRefreshAssignments();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|