We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
像下面这种模拟网络请求调用,如果 -func1 睡眠的时间比 -func2 睡眠的时间长时,为什么不会执行到NSLog(@"num = %@ -- error: %@",num,error);这句代码?
co_launch(^{ NSLog(@"co_launch1 前 -- %@",[NSThread currentThread]); NSNumber *num; NSError *error; NSArray *array = batch_await(@[[self func1], [self func2]]); NSLog(@"num = %@ -- error: %@",num,error); co_unpack(&num, &error) = array[0]; NSLog(@"co_launch1 后 -- %@",[NSThread currentThread]); });
(COPromise *)func1 { return [COPromise promise:^(COPromiseFullfill _Nonnull fullfill, COPromiseReject Nonnull reject) { dispatch_async(dispatch_get_global_queue(0, 0), ^{ NSLog(@"前 func1 -- %@",[NSThread currentThread]); [NSThread sleepForTimeInterval:5.0]; fullfill(co_tuple(@(10), [NSError errorWithDomain:@"co" code:100 userInfo:nil])); NSLog(@"后 func1 -- %@",[NSThread currentThread]); }); }]; }
(COPromise *)func2 { return [COPromise promise:^(COPromiseFullfill _Nonnull fullfill, COPromiseReject _Nonnull reject) { dispatch_async(dispatch_get_global_queue(0, 0), ^{ NSLog(@"前 func2 -- %@",[NSThread currentThread]); [NSThread sleepForTimeInterval:3.0]; fullfill(nil); NSLog(@"后 func2 -- %@",[NSThread currentThread]); }); }]; }
The text was updated successfully, but these errors were encountered:
Duplicate, #25
And it's already fixed. upgrade to 1.1.0
Sorry, something went wrong.
NianJi
No branches or pull requests
像下面这种模拟网络请求调用,如果 -func1 睡眠的时间比 -func2 睡眠的时间长时,为什么不会执行到NSLog(@"num = %@ -- error: %@",num,error);这句代码?
co_launch(^{
NSLog(@"co_launch1 前 -- %@",[NSThread currentThread]);
NSNumber *num;
NSError *error;
NSArray *array = batch_await(@[[self func1], [self func2]]);
NSLog(@"num = %@ -- error: %@",num,error);
co_unpack(&num, &error) = array[0];
NSLog(@"co_launch1 后 -- %@",[NSThread currentThread]);
});
(COPromise *)func1 {
return [COPromise promise:^(COPromiseFullfill _Nonnull fullfill, COPromiseReject Nonnull reject) {
dispatch_async(dispatch_get_global_queue(0, 0), ^{
NSLog(@"前 func1 -- %@",[NSThread currentThread]);
[NSThread sleepForTimeInterval:5.0];
fullfill(co_tuple(@(10), [NSError errorWithDomain:@"co" code:100 userInfo:nil]));
NSLog(@"后 func1 -- %@",[NSThread currentThread]);
});
}];
}
(COPromise *)func2 {
return [COPromise promise:^(COPromiseFullfill _Nonnull fullfill, COPromiseReject _Nonnull reject) {
dispatch_async(dispatch_get_global_queue(0, 0), ^{
NSLog(@"前 func2 -- %@",[NSThread currentThread]);
[NSThread sleepForTimeInterval:3.0];
fullfill(nil);
NSLog(@"后 func2 -- %@",[NSThread currentThread]);
});
}];
}
The text was updated successfully, but these errors were encountered: