blob: 03b0359278a24fbf7b3578166240fb4796102477 [file] [log] [blame]
Jorge Canizales142acc92015-05-15 18:43:34 -07001/*
2 *
3 * Copyright 2015, Google Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
34#import <Foundation/Foundation.h>
35
36#import "GRXWriteable.h"
37#import "GRXWriter.h"
38
Jorge Canizalesb10776c2015-10-26 10:44:55 -070039/**
40 * A buffered pipe is a Writer that also acts as a Writeable.
41 * Once it is started, whatever values are written into it (via -writeValue:) will be propagated
42 * immediately, unless flow control prevents it.
43 * If it is throttled and keeps receiving values, as well as if it receives values before being
44 * started, it will buffer them and propagate them in order as soon as its state becomes Started.
45 * If it receives an error (via -writesFinishedWithError:), it will drop any buffered values and
46 * propagate the error immediately.
47 *
48 * Beware that a pipe of this type can't prevent receiving more values when it is paused (for
49 * example if used to write data to a congested network connection). Because in such situations the
50 * pipe will keep buffering all data written to it, your application could run out of memory and
51 * crash. If you want to react to flow control signals to prevent that, instead of using this class
52 * you can implement an object that conforms to GRXWriter.
53 *
54 * Thread-safety:
55 * The methods of an object of this class should not be called concurrently from different threads.
56 */
Jorge Canizalesa38baae2015-07-16 21:12:56 -070057@interface GRXBufferedPipe : GRXWriter<GRXWriteable>
Jorge Canizales142acc92015-05-15 18:43:34 -070058
Jorge Canizalesb10776c2015-10-26 10:44:55 -070059/** Convenience constructor. */
Jorge Canizales142acc92015-05-15 18:43:34 -070060+ (instancetype)pipe;
61
62@end