Enum Operator.Signal

  • All Implemented Interfaces:
    Serializable, Comparable<Operator.Signal>
    Enclosing interface:
    Operator

    public static enum Operator.Signal
    extends Enum<Operator.Signal>
    This is the return object from a receiver. It is used to communicate to whatever is pushing the data into the receiver the state of processing. This exists because Operators can sometimes decide that no more results will be needed (e.g. if the result set is being limited), in which case, they need some way to communicate this to downstream processing to effectively "cancel" further computation.

    It's named weird because... well, the author had a hard time coming up with a meaningful name. Suggestions for alternate names are welcome.

    • Enum Constant Detail

      • STOP

        public static final Operator.Signal STOP
        Indicates that the downstream processing need not do anything else. Operators that return this should avoid pre-emptively calling Operator.Receiver.completed() before returning STOP. They should instead return STOP and trust that the downstream code will call Operator.Receiver.completed(). This is because downstream code *might* be pipelining computations to prepare the next set of data and if the Operator first calls Operator.Receiver.completed() before communicating that no further results are needed, it delays the canceling of the pipelined operations and effectively wastes CPU cycles.
      • PAUSE

        public static final Operator.Signal PAUSE
        Indicates that the downstream processing should pause its pushing of results and instead return a continuation object that encapsulates whatever state is required to resume processing. When this signal is received, Operators that are generating data might choose to exert backpressure or otherwise pause their processing efforts until called again with the returned continuation object.

        If an Operator has completed its processing already when this signal is received, instead of returning a continuation object, it should call Operator.Receiver.completed() and return null.

      • GO

        public static final Operator.Signal GO
        Indicates that more data is welcome.
    • Method Detail

      • values

        public static Operator.Signal[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Operator.Signal c : Operator.Signal.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Operator.Signal valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null