Merge pull request #14314 from muxi/fix-implicit-retain-self

Fix reference of self in a block
pull/14330/head
Muxi Yan 7 years ago committed by GitHub
commit cd3f579cce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/objective-c/ProtoRPC/ProtoMethod.m
  2. 3
      src/objective-c/ProtoRPC/ProtoRPC.m
  3. 3
      src/objective-c/ProtoRPC/ProtoService.m
  4. 30
      src/objective-c/RxLibrary/GRXConcurrentWriteable.m

@ -18,7 +18,10 @@
#import "ProtoMethod.h"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation ProtoMethod
#pragma clang diagnostic pop
- (instancetype)initWithPackage:(NSString *)package
service:(NSString *)service
method:(NSString *)method {

@ -42,7 +42,10 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing
userInfo:info];
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation ProtoRPC {
#pragma clang diagnostic pop
id<GRXWriteable> _responseWriteable;
}

@ -24,7 +24,10 @@
#import "ProtoMethod.h"
#import "ProtoRPC.h"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation ProtoService {
#pragma clang diagnostic pop
NSString *_host;
NSString *_packageName;
NSString *_serviceName;

@ -64,21 +64,25 @@
}
- (void)enqueueSuccessfulCompletion {
__weak typeof(self) weakSelf = self;
dispatch_async(_writeableQueue, ^{
BOOL finished = NO;
@synchronized (self) {
if (!_alreadyFinished) {
_alreadyFinished = YES;
} else {
finished = YES;
typeof(self) strongSelf = weakSelf;
if (strongSelf) {
BOOL finished = NO;
@synchronized (self) {
if (!strongSelf->_alreadyFinished) {
strongSelf->_alreadyFinished = YES;
} else {
finished = YES;
}
}
if (!finished) {
// Cancellation is now impossible. None of the other three blocks can run concurrently with
// this one.
[self.writeable writesFinishedWithError:nil];
// Skip any possible message to the wrapped writeable enqueued after this one.
self.writeable = nil;
}
}
if (!finished) {
// Cancellation is now impossible. None of the other three blocks can run concurrently with
// this one.
[self.writeable writesFinishedWithError:nil];
// Skip any possible message to the wrapped writeable enqueued after this one.
self.writeable = nil;
}
});
}

Loading…
Cancel
Save