tahoma2d/toonz/sources/common/tcore/tthreadp.h

77 lines
1.7 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef TTHREADP_H
#define TTHREADP_H
#include <QObject>
#include "tthreadmessage.h"
//=====================================================================
//======================================
// TThreadMessageDispatcher class
//--------------------------------------
2016-06-15 18:43:10 +12:00
// NOTE: This class should eventually be moved to tthreadmessagep.h...
class TThreadMessageDispatcher final : public QObject // singleton
2016-03-19 06:57:51 +13:00
{
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TThreadMessageDispatcher();
Q_SIGNALS:
void signaled(TThread::Message *msg);
void blockingSignaled(TThread::Message *msg);
2016-03-19 06:57:51 +13:00
protected Q_SLOTS:
2016-06-15 18:43:10 +12:00
void onSignal(TThread::Message *msg);
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
void emitSignaled(TThread::Message *msg);
void emitBlockingSignaled(TThread::Message *msg);
static void init();
static TThreadMessageDispatcher *instance();
2016-03-19 06:57:51 +13:00
};
//=====================================================================
2016-06-15 18:43:10 +12:00
namespace TThread {
// Forward declarations
2016-03-19 06:57:51 +13:00
class ExecutorId;
class ExecutorImpSlots;
}
//=====================================================================
//==============================
// ExecutorImpSlots class
//------------------------------
class TThread::ExecutorImpSlots final : public QObject {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
ExecutorImpSlots();
~ExecutorImpSlots();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// The following is provided to ensure that point #3 in Qt reference in page
// "Thread support in Qt"
// is satisfied:
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// "You must ensure that all objects created in
// a thread are deleted before you delete the QThread."
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// So, specifically, thread creation should happen only in the main thread,
// not in worker threads.
void emitRefreshAssignments();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
Q_SIGNALS:
void refreshAssignments();
2016-03-19 06:57:51 +13:00
public Q_SLOTS:
2016-06-15 18:43:10 +12:00
void onTerminated();
void onRefreshAssignments();
2016-03-19 06:57:51 +13:00
};
#endif