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

View File

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

View File

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

View File

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