Skip to content
New issue

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

Rename GRXWriteable methods #1664

Merged
merged 2 commits into from
May 20, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
s/didReceiveValue/writeValue
  • Loading branch information
jcanizales committed May 19, 2015
commit a90a9c395d86b5f1e6b123ae25de14c7f0362040
2 changes: 1 addition & 1 deletion src/objective-c/GRPCClient/GRPCCall.m
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ - (void)writeMessage:(NSData *)message withErrorHandler:(void (^)())errorHandler
handler:resumingHandler]] errorHandler:errorHandler];
}

- (void)didReceiveValue:(id)value {
- (void)writeValue:(id)value {
// TODO(jcanizales): Throw/assert if value isn't NSData.

// Pause the input and only resume it when the C layer notifies us that writes
Expand Down
5 changes: 2 additions & 3 deletions src/objective-c/GRPCClient/private/GRPCDelegateWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@
- (instancetype)initWithWriteable:(id<GRXWriteable>)writeable writer:(id<GRXWriter>)writer
NS_DESIGNATED_INITIALIZER;

// Enqueues didReceiveValue: to be sent to the writeable in the main thread.
// The passed handler is invoked from the main thread after didReceiveValue:
// returns.
// 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;

// Enqueues didFinishWithError:nil to be sent to the writeable in the main
Expand Down
2 changes: 1 addition & 1 deletion src/objective-c/GRPCClient/private/GRPCDelegateWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ - (void)enqueueMessage:(NSData *)message completionHandler:(void (^)())handler {
// the race.
id<GRXWriteable> writeable = self.writeable;
if (writeable) {
[writeable didReceiveValue:message];
[writeable writeValue:message];
handler();
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/objective-c/ProtoRPC/ProtoRPC.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ - (instancetype)initWithHost:(NSString *)host
if ((self = [super initWithHost:host method:method requestsWriter:bytesWriter])) {
// A writeable that parses the proto messages received.
_responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
[responsesWriteable didReceiveValue:[responseClass parseFromData:value]];
[responsesWriteable writeValue:[responseClass parseFromData:value]];
} completionHandler:^(NSError *errorOrNil) {
[responsesWriteable didFinishWithError:errorOrNil];
}];
Expand Down
4 changes: 2 additions & 2 deletions src/objective-c/RxLibrary/GRXBufferedPipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

// A buffered pipe is a Writeable that also acts as a Writer (to whichever other writeable is passed
// to -startWithWriteable:).
// Once it is started, whatever values are written into it (via -didReceiveValue:) will be
// propagated immediately, unless flow control prevents it.
// Once it is started, whatever values are written into it (via -writeValue:) will be propagated
// immediately, unless flow control prevents it.
// If it is throttled and keeps receiving values, as well as if it receives values before being
// started, it will buffer them and propagate them in order as soon as its state becomes
// GRXWriterStateStarted.
Expand Down
6 changes: 3 additions & 3 deletions src/objective-c/RxLibrary/GRXBufferedPipe.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ - (id)popValue {

- (void)writeBufferUntilPausedOrStopped {
while (_state == GRXWriterStateStarted && _queue.count > 0) {
[_writeable didReceiveValue:[self popValue]];
[_writeable writeValue:[self popValue]];
}
if (_inputIsFinished && _queue.count == 0) {
// Our writer finished normally while we were paused or not-started-yet.
Expand All @@ -77,10 +77,10 @@ - (BOOL)shouldFastForward {
return _state == GRXWriterStateStarted && _queue.count == 0;
}

- (void)didReceiveValue:(id)value {
- (void)writeValue:(id)value {
if (self.shouldFastForward) {
// Skip the queue.
[_writeable didReceiveValue:value];
[_writeable writeValue:value];
} else {
// Even if we're paused and with enqueued values, we can't excert back-pressure to our writer.
// So just buffer the new value.
Expand Down
2 changes: 1 addition & 1 deletion src/objective-c/RxLibrary/GRXImmediateWriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ + (instancetype)writerWithEnumerator:(NSEnumerator *)enumerator error:(NSError *
- (void)writeUntilPausedOrStopped {
id value;
while (value = [_enumerator nextObject]) {
[_writeable didReceiveValue:value];
[_writeable writeValue:value];
// If the writeable has a reference to us, it might change our state to paused or finished.
if (_state == GRXWriterStatePaused || _state == GRXWriterStateFinished) {
return;
Expand Down
5 changes: 2 additions & 3 deletions src/objective-c/RxLibrary/GRXWriteable.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@
@protocol GRXWriteable <NSObject>

// Push the next value of the sequence to the receiving object.
// TODO(jcanizales): Name it enumerator:(id<GRXEnumerator>) didProduceValue:(id)?
- (void)didReceiveValue:(id)value;
- (void)writeValue:(id)value;

// Signal that the sequence is completed, or that an error ocurred. After this
// message is sent to the instance, neither it nor didReceiveValue: may be
// message is sent to the instance, neither it nor writeValue: may be
// called again.
// TODO(jcanizales): enumerator:(id<GRXEnumerator>) didFinishWithError:(NSError*)?
- (void)didFinishWithError:(NSError *)errorOrNil;
Expand Down
2 changes: 1 addition & 1 deletion src/objective-c/RxLibrary/GRXWriteable.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ - (instancetype)initWithValueHandler:(GRXValueHandler)valueHandler
return self;
}

- (void)didReceiveValue:(id)value {
- (void)writeValue:(id)value {
if (_valueHandler) {
_valueHandler(value);
}
Expand Down
4 changes: 2 additions & 2 deletions src/objective-c/RxLibrary/GRXWriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ - (void)finishInput {

#pragma mark GRXWriteable implementation

- (void)didReceiveValue:(id)value {
[_writeable didReceiveValue:value];
- (void)writeValue:(id)value {
[_writeable writeValue:value];
}

- (void)didFinishWithError:(NSError *)errorOrNil {
Expand Down
4 changes: 2 additions & 2 deletions src/objective-c/RxLibrary/transformations/GRXMappingWriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ - (instancetype)initWithWriter:(id<GRXWriter>)writer map:(id (^)(id value))map {
}

// Override
- (void)didReceiveValue:(id)value {
[super didReceiveValue:_map(value)];
- (void)writeValue:(id)value {
[super writeValue:_map(value)];
}
@end
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ - (void)testPingPongRPC {

id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index]
requestedResponseSize:responses[index]];
[requestsBuffer didReceiveValue:request];
[requestsBuffer writeValue:request];

[_service fullDuplexCallWithRequestsWriter:requestsBuffer
handler:^(BOOL done,
Expand All @@ -225,7 +225,7 @@ - (void)testPingPongRPC {
if (index < 4) {
id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index]
requestedResponseSize:responses[index]];
[requestsBuffer didReceiveValue:request];
[requestsBuffer writeValue:request];
} else {
[requestsBuffer didFinishWithError:nil];
}
Expand Down