|
|
@ -38,11 +38,11 @@ |
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
// (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
|
|
|
|
// TODO(jcanizales): Let the user specify another queue for the writeable
|
|
|
|
// callbacks.
|
|
|
|
// callbacks.
|
|
|
@ -51,7 +51,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
// This is used to create a retain cycle that keeps both objects alive until the
|
|
|
|
// writing is explicitly finished.
|
|
|
|
// writing is explicitly finished.
|
|
|
|
- (instancetype)initWithWriteable:(id<GRXWriteable>)writeable writer:(id<GRXWriter>)writer |
|
|
|
- (instancetype)initWithWriteable:(id<GRXWriteable>)writeable writer:(id<GRXWriter>)writer |
|
|
@ -61,12 +61,12 @@ |
|
|
|
// 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)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
|
|
|
|
// thread. After that message is sent to the writeable, all other methods of
|
|
|
|
// this object are effectively noops.
|
|
|
|
// this object are effectively noops.
|
|
|
|
- (void)enqueueSuccessfulCompletion; |
|
|
|
- (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
|
|
|
|
// 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
|
|
|
|
// pending messages to the writeable enqueued by this object (both past and
|
|
|
|
// future).
|
|
|
|
// future).
|
|
|
@ -74,7 +74,7 @@ |
|
|
|
- (void)cancelWithError:(NSError *)error; |
|
|
|
- (void)cancelWithError:(NSError *)error; |
|
|
|
|
|
|
|
|
|
|
|
// Cancels all pending messages to the writeable enqueued by this object (both
|
|
|
|
// 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.
|
|
|
|
// this also releases the writeable and the writer.
|
|
|
|
- (void)cancelSilently; |
|
|
|
- (void)cancelSilently; |
|
|
|
@end |
|
|
|
@end |
|
|
|