ConcurrentWriteable: NSData *message -> id value

pull/2499/head
Jorge Canizales 10 years ago
parent 35f003b24e
commit 4c6f778cfd
  1. 2
      src/objective-c/GRPCClient/GRPCCall.m
  2. 8
      src/objective-c/RxLibrary/GRXConcurrentWriteable.h
  3. 4
      src/objective-c/RxLibrary/GRXConcurrentWriteable.m

@ -216,7 +216,7 @@ NSString * const kGRPCStatusMetadataKey = @"io.grpc.StatusMetadataKey";
[weakSelf cancelCall];
return;
}
[weakWriteable enqueueMessage:data completionHandler:^{
[weakWriteable enqueueValue:data completionHandler:^{
[weakSelf startNextRead];
}];
}];

@ -33,9 +33,8 @@
#import <Foundation/Foundation.h>
#import <RxLibrary/GRXWriter.h>
@protocol GRXWriteable;
#import "GRXWriter.h"
#import "GRXWriteable.h"
// This is a thread-safe wrapper over a GRXWriteable instance. It lets one
// enqueue calls to a GRXWriteable instance for the main thread, guaranteeing
@ -47,7 +46,6 @@
//
// TODO(jcanizales): Let the user specify another queue for the writeable
// callbacks.
// TODO(jcanizales): Rename to GRXWriteableWrapper and move to the Rx library.
@interface GRXConcurrentWriteable : NSObject
// The GRXWriteable passed is the wrapped writeable.
@ -60,7 +58,7 @@
// Enqueues writeValue: to be sent to the writeable in the main thread.
// The passed handler is invoked from the main thread after writeValue: returns.
- (void)enqueueMessage:(NSData *)message completionHandler:(void (^)())handler;
- (void)enqueueValue:(id)value completionHandler:(void (^)())handler;
// Enqueues writesFinishedWithError:nil to be sent to the writeable in the main
// thread. After that message is sent to the writeable, all other methods of

@ -61,7 +61,7 @@
return self;
}
- (void)enqueueMessage:(NSData *)message completionHandler:(void (^)())handler {
- (void)enqueueValue:(id)value completionHandler:(void (^)())handler {
dispatch_async(_writeableQueue, ^{
// We're racing a possible cancellation performed by another thread. To turn
// all already-enqueued messages into noops, cancellation nillifies the
@ -69,7 +69,7 @@
// the race.
id<GRXWriteable> writeable = self.writeable;
if (writeable) {
[writeable writeValue:message];
[writeable writeValue:value];
handler();
}
});

Loading…
Cancel
Save