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