|
|
|
@ -38,11 +38,11 @@ |
|
|
|
|
|
|
|
|
|
// This is a thread-safe wrapper over a GRXWriteable instance. It lets one
|
|
|
|
|
// enqueue calls to a GRXWriteable instance for the main thread, guaranteeing
|
|
|
|
|
// that didFinishWithError: is the last message sent to it (no matter what
|
|
|
|
|
// that writesFinishedWithError: is the last message sent to it (no matter what
|
|
|
|
|
// messages are sent to the wrapper, in what order, nor from which thread). It
|
|
|
|
|
// also guarantees that, if cancelWithError: is called from the main thread
|
|
|
|
|
// (e.g. by the app cancelling the writes), no further messages are sent to the
|
|
|
|
|
// writeable except didFinishWithError:.
|
|
|
|
|
// writeable except writesFinishedWithError:.
|
|
|
|
|
//
|
|
|
|
|
// TODO(jcanizales): Let the user specify another queue for the writeable
|
|
|
|
|
// callbacks.
|
|
|
|
@ -51,23 +51,22 @@ |
|
|
|
|
|
|
|
|
|
// The GRXWriteable passed is the wrapped writeable.
|
|
|
|
|
// Both the GRXWriter instance and the GRXWriteable instance are retained until
|
|
|
|
|
// didFinishWithError: is sent to the writeable, and released after that.
|
|
|
|
|
// writesFinishedWithError: is sent to the writeable, and released after that.
|
|
|
|
|
// This is used to create a retain cycle that keeps both objects alive until the
|
|
|
|
|
// writing is explicitly finished.
|
|
|
|
|
- (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
|
|
|
|
|
// 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
|
|
|
|
|
// this object are effectively noops.
|
|
|
|
|
- (void)enqueueSuccessfulCompletion; |
|
|
|
|
|
|
|
|
|
// If the writeable has not yet received a didFinishWithError: message, this
|
|
|
|
|
// If the writeable has not yet received a writesFinishedWithError: message, this
|
|
|
|
|
// will enqueue one to be sent to it in the main thread, and cancel all other
|
|
|
|
|
// pending messages to the writeable enqueued by this object (both past and
|
|
|
|
|
// future).
|
|
|
|
@ -75,7 +74,7 @@ |
|
|
|
|
- (void)cancelWithError:(NSError *)error; |
|
|
|
|
|
|
|
|
|
// Cancels all pending messages to the writeable enqueued by this object (both
|
|
|
|
|
// past and future). Because the writeable won't receive didFinishWithError:,
|
|
|
|
|
// past and future). Because the writeable won't receive writesFinishedWithError:,
|
|
|
|
|
// this also releases the writeable and the writer.
|
|
|
|
|
- (void)cancelSilently; |
|
|
|
|
@end |
|
|
|
|