add thread mode & async call

This commit is contained in:
王劲鹏 2021-02-07 11:21:53 +08:00 committed by osborn
parent 24f7bb2498
commit ceb08bfa1d
5 changed files with 23 additions and 0 deletions

View File

@ -1,10 +1,13 @@
#ifndef INTERFACEDRIVER_H #ifndef INTERFACEDRIVER_H
#define INTERFACEDRIVER_H #define INTERFACEDRIVER_H
#include <QRunnable>
#include <QString> #include <QString>
#include <QVariant> #include <QVariant>
#include "DoricRegistry.h" #include "DoricRegistry.h"
#include "async/DoricAsyncResult.h"
#include "utils/DoricThreadMode.h"
class DoricInterfaceDriver { class DoricInterfaceDriver {
public: public:
@ -13,6 +16,9 @@ public:
virtual void invokeDoricMethod(QString method, QVariantList args) = 0; virtual void invokeDoricMethod(QString method, QVariantList args) = 0;
virtual DoricAsyncResult *asyncCall(QRunnable *runnable,
DoricThreadMode mode) = 0;
virtual void createContext(QString contextId, QString script, virtual void createContext(QString contextId, QString script,
QString source) = 0; QString source) = 0;

View File

@ -19,6 +19,11 @@ void DoricNativeDriver::invokeDoricMethod(QString method, QVariantList args) {
}); });
} }
DoricAsyncResult *DoricNativeDriver::asyncCall(QRunnable *runnable,
DoricThreadMode mode) {
return NULL;
}
void DoricNativeDriver::createContext(QString contextId, QString script, void DoricNativeDriver::createContext(QString contextId, QString script,
QString source) { QString source) {
DoricAsyncCall::ensureRunInThreadPool( DoricAsyncCall::ensureRunInThreadPool(

View File

@ -26,6 +26,8 @@ public:
void invokeDoricMethod(QString method, QVariantList args) override; void invokeDoricMethod(QString method, QVariantList args) override;
DoricAsyncResult * asyncCall(QRunnable *runnable, DoricThreadMode mode) override;
void createContext(QString contextId, QString script, void createContext(QString contextId, QString script,
QString source) override; QString source) override;

View File

@ -76,4 +76,5 @@ HEADERS += \
utils/DoricContextHolder.h \ utils/DoricContextHolder.h \
utils/DoricCountDownLatch.h \ utils/DoricCountDownLatch.h \
utils/DoricObjectFactory.h \ utils/DoricObjectFactory.h \
utils/DoricThreadMode.h \
utils/DoricUtils.h utils/DoricUtils.h

View File

@ -0,0 +1,9 @@
#ifndef DORICTHREADMODE_H
#define DORICTHREADMODE_H
enum DoricThreadMode {
UI,
JS,
};
#endif // DORICTHREADMODE_H