Rename GRPCDelegateWrapper -> GRXConcurrentWriteable

And move it to the RxLibrary.
pull/2499/head
Jorge Canizales 10 years ago
parent f87a0984ab
commit 35f003b24e
  1. 8
      src/objective-c/GRPCClient/GRPCCall.m
  2. 2
      src/objective-c/RxLibrary/GRXConcurrentWriteable.h
  3. 6
      src/objective-c/RxLibrary/GRXConcurrentWriteable.m

@ -35,10 +35,10 @@
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
#import <RxLibrary/GRXConcurrentWriteable.h>
#import "private/GRPCChannel.h" #import "private/GRPCChannel.h"
#import "private/GRPCCompletionQueue.h" #import "private/GRPCCompletionQueue.h"
#import "private/GRPCDelegateWrapper.h"
#import "private/GRPCWrappedCall.h" #import "private/GRPCWrappedCall.h"
#import "private/NSData+GRPC.h" #import "private/NSData+GRPC.h"
#import "private/NSDictionary+GRPC.h" #import "private/NSDictionary+GRPC.h"
@ -78,7 +78,7 @@ NSString * const kGRPCStatusMetadataKey = @"io.grpc.StatusMetadataKey";
// do. Particularly, in the face of errors, there's no ordering guarantee at // do. Particularly, in the face of errors, there's no ordering guarantee at
// all. This wrapper over our actual writeable ensures thread-safety and // all. This wrapper over our actual writeable ensures thread-safety and
// correct ordering. // correct ordering.
GRPCDelegateWrapper *_responseWriteable; GRXConcurrentWriteable *_responseWriteable;
GRXWriter *_requestWriter; GRXWriter *_requestWriter;
NSMutableDictionary *_requestMetadata; NSMutableDictionary *_requestMetadata;
@ -191,7 +191,7 @@ NSString * const kGRPCStatusMetadataKey = @"io.grpc.StatusMetadataKey";
return; return;
} }
__weak GRPCCall *weakSelf = self; __weak GRPCCall *weakSelf = self;
__weak GRPCDelegateWrapper *weakWriteable = _responseWriteable; __weak GRXConcurrentWriteable *weakWriteable = _responseWriteable;
dispatch_async(_callQueue, ^{ dispatch_async(_callQueue, ^{
[weakSelf startReadWithHandler:^(grpc_byte_buffer *message) { [weakSelf startReadWithHandler:^(grpc_byte_buffer *message) {
@ -340,7 +340,7 @@ NSString * const kGRPCStatusMetadataKey = @"io.grpc.StatusMetadataKey";
// Care is taken not to retain self strongly in any of the blocks used in // Care is taken not to retain self strongly in any of the blocks used in
// the implementation of GRPCCall, so that the life of the instance is // the implementation of GRPCCall, so that the life of the instance is
// determined by this retain cycle. // determined by this retain cycle.
_responseWriteable = [[GRPCDelegateWrapper alloc] initWithWriteable:writeable writer:self]; _responseWriteable = [[GRXConcurrentWriteable alloc] initWithWriteable:writeable writer:self];
[self sendHeaders:_requestMetadata]; [self sendHeaders:_requestMetadata];
[self invokeCall]; [self invokeCall];
} }

@ -48,7 +48,7 @@
// TODO(jcanizales): Let the user specify another queue for the writeable // TODO(jcanizales): Let the user specify another queue for the writeable
// callbacks. // callbacks.
// TODO(jcanizales): Rename to GRXWriteableWrapper and move to the Rx library. // TODO(jcanizales): Rename to GRXWriteableWrapper and move to the Rx library.
@interface GRPCDelegateWrapper : NSObject @interface GRXConcurrentWriteable : NSObject
// The GRXWriteable passed is the wrapped writeable. // The GRXWriteable passed is the wrapped writeable.
// Both the GRXWriter instance and the GRXWriteable instance are retained until // Both the GRXWriter instance and the GRXWriteable instance are retained until

@ -31,17 +31,17 @@
* *
*/ */
#import "GRPCDelegateWrapper.h" #import "GRXConcurrentWriteable.h"
#import <RxLibrary/GRXWriteable.h> #import <RxLibrary/GRXWriteable.h>
@interface GRPCDelegateWrapper () @interface GRXConcurrentWriteable ()
// These are atomic so that cancellation can nillify them from any thread. // These are atomic so that cancellation can nillify them from any thread.
@property(atomic, strong) id<GRXWriteable> writeable; @property(atomic, strong) id<GRXWriteable> writeable;
@property(atomic, strong) GRXWriter *writer; @property(atomic, strong) GRXWriter *writer;
@end @end
@implementation GRPCDelegateWrapper { @implementation GRXConcurrentWriteable {
dispatch_queue_t _writeableQueue; dispatch_queue_t _writeableQueue;
// This ensures that writesFinishedWithError: is only sent once to the writeable. // This ensures that writesFinishedWithError: is only sent once to the writeable.
dispatch_once_t _alreadyFinished; dispatch_once_t _alreadyFinished;
Loading…
Cancel
Save