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]; [weakSelf cancelCall];
return; return;
} }
[weakWriteable enqueueMessage:data completionHandler:^{ [weakWriteable enqueueValue:data completionHandler:^{
[weakSelf startNextRead]; [weakSelf startNextRead];
}]; }];
}]; }];

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

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

Loading…
Cancel
Save