iOS:JS operation use seperated thread
This commit is contained in:
@@ -56,7 +56,7 @@ + (instancetype)instance {
|
||||
- (DoricAsyncResult *)invokeDoricMethod:(NSString *)method argumentsArray:(NSArray *)args {
|
||||
DoricAsyncResult *ret = [[DoricAsyncResult alloc] init];
|
||||
__weak typeof(self) _self = self;
|
||||
dispatch_async(self.jsExecutor.jsQueue, ^() {
|
||||
[self.jsExecutor ensureRunOnJSThread:^{
|
||||
__strong typeof(_self) self = _self;
|
||||
if (!self) return;
|
||||
@try {
|
||||
@@ -65,7 +65,7 @@ - (DoricAsyncResult *)invokeDoricMethod:(NSString *)method argumentsArray:(NSArr
|
||||
} @catch (NSException *exception) {
|
||||
[ret setupError:exception];
|
||||
}
|
||||
});
|
||||
}];
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ - (DoricAsyncResult *)invokeDoricMethod:(NSString *)method argumentsArray:(NSArr
|
||||
[array addObject:arg];
|
||||
}
|
||||
__weak typeof(self) _self = self;
|
||||
dispatch_async(self.jsExecutor.jsQueue, ^() {
|
||||
[self.jsExecutor ensureRunOnJSThread:^{
|
||||
__strong typeof(_self) self = _self;
|
||||
if (!self) return;
|
||||
@try {
|
||||
@@ -94,7 +94,7 @@ - (DoricAsyncResult *)invokeDoricMethod:(NSString *)method argumentsArray:(NSArr
|
||||
} @catch (NSException *exception) {
|
||||
[ret setupError:exception];
|
||||
}
|
||||
});
|
||||
}];
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ - (DoricAsyncResult *)invokeContextEntity:(NSString *)contextId method:(NSString
|
||||
arg = va_arg(args, JSValue *);
|
||||
}
|
||||
__weak typeof(self) _self = self;
|
||||
dispatch_async(self.jsExecutor.jsQueue, ^() {
|
||||
[self.jsExecutor ensureRunOnJSThread:^{
|
||||
__strong typeof(_self) self = _self;
|
||||
if (!self) return;
|
||||
@try {
|
||||
@@ -127,7 +127,7 @@ - (DoricAsyncResult *)invokeContextEntity:(NSString *)contextId method:(NSString
|
||||
[ret setupError:exception];
|
||||
[self.jsExecutor.registry onException:exception inContext:[[DoricContextManager instance] getContext:contextId]];
|
||||
}
|
||||
});
|
||||
}];
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ - (DoricAsyncResult *)invokeContextEntity:(NSString *)contextId method:(NSString
|
||||
[array addObject:arg];
|
||||
}
|
||||
__weak typeof(self) _self = self;
|
||||
dispatch_async(self.jsExecutor.jsQueue, ^() {
|
||||
[self.jsExecutor ensureRunOnJSThread:^{
|
||||
__strong typeof(_self) self = _self;
|
||||
if (!self) return;
|
||||
@try {
|
||||
@@ -150,14 +150,14 @@ - (DoricAsyncResult *)invokeContextEntity:(NSString *)contextId method:(NSString
|
||||
[ret setupError:exception];
|
||||
[self.jsExecutor.registry onException:exception inContext:[[DoricContextManager instance] getContext:contextId]];
|
||||
}
|
||||
});
|
||||
}];
|
||||
return ret;
|
||||
}
|
||||
|
||||
- (DoricAsyncResult *)createContext:(NSString *)contextId script:(NSString *)script source:(NSString *)source {
|
||||
DoricAsyncResult *ret = [[DoricAsyncResult alloc] init];
|
||||
__weak typeof(self) _self = self;
|
||||
dispatch_async(self.jsExecutor.jsQueue, ^() {
|
||||
[self.jsExecutor ensureRunOnJSThread:^{
|
||||
__strong typeof(_self) self = _self;
|
||||
if (!self) return;
|
||||
@try {
|
||||
@@ -167,14 +167,14 @@ - (DoricAsyncResult *)createContext:(NSString *)contextId script:(NSString *)scr
|
||||
[ret setupError:exception];
|
||||
[self.registry onException:exception inContext:[[DoricContextManager instance] getContext:contextId]];
|
||||
}
|
||||
});
|
||||
}];
|
||||
return ret;
|
||||
}
|
||||
|
||||
- (DoricAsyncResult *)destroyContext:(NSString *)contextId {
|
||||
DoricAsyncResult *ret = [[DoricAsyncResult alloc] init];
|
||||
__weak typeof(self) _self = self;
|
||||
dispatch_async(self.jsExecutor.jsQueue, ^() {
|
||||
[self.jsExecutor ensureRunOnJSThread:^{
|
||||
__strong typeof(_self) self = _self;
|
||||
if (!self) return;
|
||||
@try {
|
||||
@@ -184,7 +184,7 @@ - (DoricAsyncResult *)destroyContext:(NSString *)contextId {
|
||||
[ret setupError:exception];
|
||||
[self.jsExecutor.registry onException:exception inContext:[[DoricContextManager instance] getContext:contextId]];
|
||||
}
|
||||
});
|
||||
}];
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user