You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by mo...@apache.org on 2019/04/22 12:55:55 UTC
[incubator-weex] branch master updated: [iOS] support download js
by multithread
This is an automated email from the ASF dual-hosted git repository.
moshen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push:
new a88c087 [iOS] support download js by multithread
new 449975e Merge pull request #2345 from jianhan-he/master
a88c087 is described below
commit a88c0875fd7b6f89d72928b195873d4001ac6904
Author: linghe.lh <li...@alibaba-inc.com>
AuthorDate: Mon Apr 22 17:24:19 2019 +0800
[iOS] support download js by multithread
---
ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.h | 3 +++
ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm | 7 +++++++
weex_core/Source/core/bridge/eagle_bridge.cpp | 4 ++++
weex_core/Source/core/bridge/eagle_bridge.h | 2 ++
weex_core/Source/core/bridge/platform_bridge.h | 2 ++
weex_core/Source/core/network/ios/default_request_handler.mm | 4 +---
6 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.h b/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.h
index 7e73bd0..dace1ac 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.h
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.h
@@ -24,6 +24,7 @@
#include "core/bridge/platform_bridge.h"
#include "core/layout/measure_func_adapter.h"
+#include "base/closure.h"
namespace WeexCore
{
@@ -124,6 +125,8 @@ namespace WeexCore
}
void OnReceivedResult(long callback_id, std::unique_ptr<WeexJSResult>& result) override {};
+
+ void PostTaskOnComponentThread(const weex::base::Closure closure) override;
};
class WXCoreMeasureFunctionBridge : public MeasureFunctionAdapter
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm b/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm
index dd1aca7..8bb2624 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm
@@ -876,6 +876,13 @@ break; \
page->CallBridgeTime(getCurrentTime() - startTime);
return result;
}
+
+ void IOSSide::PostTaskOnComponentThread(const weex::base::Closure closure) {
+ WXPerformBlockOnComponentThread(^{
+ closure();
+ });
+ }
+
#pragma mark - Layout Impl
WXCoreSize WXCoreMeasureFunctionBridge::Measure(const char* page_id, long render_ptr, float width, MeasureMode widthMeasureMode, float height, MeasureMode heightMeasureMode)
diff --git a/weex_core/Source/core/bridge/eagle_bridge.cpp b/weex_core/Source/core/bridge/eagle_bridge.cpp
index d30f78f..82dcf6e 100644
--- a/weex_core/Source/core/bridge/eagle_bridge.cpp
+++ b/weex_core/Source/core/bridge/eagle_bridge.cpp
@@ -158,6 +158,10 @@ namespace WeexCore {
->platform_side()
->RegisterPluginModule(name.c_str(), class_name.c_str(), version.c_str());
}
+
+ void EagleBridge::WeexCoreHandler::PostTaskOnComponentThread(const weex::base::Closure& closure) {
+ WeexCoreManager::Instance()->getPlatformBridge()->platform_side()->PostTaskOnComponentThread(closure);
+ }
#endif
void EagleBridge::WeexCoreHandler::CallNativeComponent(const char* page_id, const char* module, const char* method,const char* arguments, int arguments_length, const char* options, int options_length) {
WeexCoreManager::Instance()
diff --git a/weex_core/Source/core/bridge/eagle_bridge.h b/weex_core/Source/core/bridge/eagle_bridge.h
index 2f98be8..7ae2c23 100644
--- a/weex_core/Source/core/bridge/eagle_bridge.h
+++ b/weex_core/Source/core/bridge/eagle_bridge.h
@@ -107,6 +107,8 @@ namespace WeexCore {
void PostTaskToMsgLoop(const weex::base::Closure& closure);
#if OS_IOS
std::unique_ptr<ValueWithType> RegisterPluginModule(const std::string &name, const std::string &class_name, const std::string &version);
+
+ void PostTaskOnComponentThread(const weex::base::Closure& closure);
#endif
};
diff --git a/weex_core/Source/core/bridge/platform_bridge.h b/weex_core/Source/core/bridge/platform_bridge.h
index c5954c7..b994847 100644
--- a/weex_core/Source/core/bridge/platform_bridge.h
+++ b/weex_core/Source/core/bridge/platform_bridge.h
@@ -25,6 +25,7 @@
#include <string>
#include <vector>
#include "base/common.h"
+#include "base/closure.h"
#include "include/WeexApiHeader.h"
namespace WeexCore {
@@ -171,6 +172,7 @@ class PlatformBridge {
int options_length) = 0;
#if OS_IOS
virtual std::unique_ptr<ValueWithType> RegisterPluginModule(const char *name, const char *class_name, const char *version) = 0;
+ virtual void PostTaskOnComponentThread(const weex::base::Closure closure) = 0;
#endif
virtual void SetTimeout(const char* callback_id, const char* time) = 0;
virtual void NativeLog(const char* str_array) = 0;
diff --git a/weex_core/Source/core/network/ios/default_request_handler.mm b/weex_core/Source/core/network/ios/default_request_handler.mm
index 0f19722..a6a35db 100644
--- a/weex_core/Source/core/network/ios/default_request_handler.mm
+++ b/weex_core/Source/core/network/ios/default_request_handler.mm
@@ -33,9 +33,7 @@ namespace network {
NSURL* nsURL = [NSURL URLWithString:NSSTRING(url)];
[[WXSDKManager bridgeMgr] DownloadJS:nsURL completion:^(NSString *script) {
WXPerformBlockOnBridgeThread(^{
- WXPerformBlockOnComponentThread(^{
- callback([script UTF8String] ? : "");
- });
+ callback([script UTF8String] ? : "");
});
}];
}