From ceb08bfa1d252ff5bf8228a5b6de90790af48318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Sun, 7 Feb 2021 11:21:53 +0800 Subject: [PATCH] add thread mode & async call --- doric-Qt/doric/DoricInterfaceDriver.h | 6 ++++++ doric-Qt/doric/DoricNativeDriver.cpp | 5 +++++ doric-Qt/doric/DoricNativeDriver.h | 2 ++ doric-Qt/doric/doric.pro | 1 + doric-Qt/doric/utils/DoricThreadMode.h | 9 +++++++++ 5 files changed, 23 insertions(+) create mode 100644 doric-Qt/doric/utils/DoricThreadMode.h diff --git a/doric-Qt/doric/DoricInterfaceDriver.h b/doric-Qt/doric/DoricInterfaceDriver.h index 6b4829d5..7e630667 100644 --- a/doric-Qt/doric/DoricInterfaceDriver.h +++ b/doric-Qt/doric/DoricInterfaceDriver.h @@ -1,10 +1,13 @@ #ifndef INTERFACEDRIVER_H #define INTERFACEDRIVER_H +#include #include #include #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; diff --git a/doric-Qt/doric/DoricNativeDriver.cpp b/doric-Qt/doric/DoricNativeDriver.cpp index fd56a360..f35dc323 100644 --- a/doric-Qt/doric/DoricNativeDriver.cpp +++ b/doric-Qt/doric/DoricNativeDriver.cpp @@ -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( diff --git a/doric-Qt/doric/DoricNativeDriver.h b/doric-Qt/doric/DoricNativeDriver.h index cec3d0ca..48f54494 100644 --- a/doric-Qt/doric/DoricNativeDriver.h +++ b/doric-Qt/doric/DoricNativeDriver.h @@ -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; diff --git a/doric-Qt/doric/doric.pro b/doric-Qt/doric/doric.pro index b22c130b..71a22e42 100644 --- a/doric-Qt/doric/doric.pro +++ b/doric-Qt/doric/doric.pro @@ -76,4 +76,5 @@ HEADERS += \ utils/DoricContextHolder.h \ utils/DoricCountDownLatch.h \ utils/DoricObjectFactory.h \ + utils/DoricThreadMode.h \ utils/DoricUtils.h diff --git a/doric-Qt/doric/utils/DoricThreadMode.h b/doric-Qt/doric/utils/DoricThreadMode.h new file mode 100644 index 00000000..3a0c67be --- /dev/null +++ b/doric-Qt/doric/utils/DoricThreadMode.h @@ -0,0 +1,9 @@ +#ifndef DORICTHREADMODE_H +#define DORICTHREADMODE_H + +enum DoricThreadMode { + UI, + JS, +}; + +#endif // DORICTHREADMODE_H