Home | History | Annotate | Download | only in RxLibrary
      1 /*
      2  *
      3  * Copyright 2015 gRPC authors.
      4  *
      5  * Licensed under the Apache License, Version 2.0 (the "License");
      6  * you may not use this file except in compliance with the License.
      7  * You may obtain a copy of the License at
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  *
     17  */
     18 
     19 #import <Foundation/Foundation.h>
     20 
     21 #import "GRXWriteable.h"
     22 #import "GRXWriter.h"
     23 
     24 /**
     25  * A buffered pipe is a Writer that also acts as a Writeable.
     26  * Once it is started, whatever values are written into it (via -writeValue:) will be propagated
     27  * immediately, unless flow control prevents it.
     28  * If it is throttled and keeps receiving values, as well as if it receives values before being
     29  * started, it will buffer them and propagate them in order as soon as its state becomes Started.
     30  * If it receives an end of stream (via -writesFinishedWithError:), it will buffer the EOS after the
     31  * last buffered value and issue it to the writeable after all buffered values are issued.
     32  *
     33  * Beware that a pipe of this type can't prevent receiving more values when it is paused (for
     34  * example if used to write data to a congested network connection). Because in such situations the
     35  * pipe will keep buffering all data written to it, your application could run out of memory and
     36  * crash. If you want to react to flow control signals to prevent that, instead of using this class
     37  * you can implement an object that conforms to GRXWriter.
     38  *
     39  * Thread-safety:
     40  * The methods of an object of this class should not be called concurrently from different threads.
     41  */
     42 @interface GRXBufferedPipe : GRXWriter<GRXWriteable>
     43 
     44 /** Convenience constructor. */
     45 + (instancetype)pipe;
     46 
     47 @end
     48