Interface ZDispenser<T>

Type Parameters:
T - type of the buffered objects.
All Known Implementing Classes:
Channel

public interface ZDispenser<T>
Used by ZBuffer to dispense buffered objects.

A ZBuffer that runs on its own thread uses an implementation of this interface for dispensing the pulled objects.

See Also:
ZBuffer
  • Method Summary

    Modifier and Type Method Description
    void dispense​(T object, boolean urgent)
    Dispenses the objects pulled from the associated ZBuffer object.
    void handleException​(Exception ex)
    Handles an exception occurred while processing the associated ZBuffer object.
  • Method Details

    • dispense

      void dispense​(T object, boolean urgent)
      Dispenses the objects pulled from the associated ZBuffer object.

      Implement this method to handle objects that are pulled from the associated buffer. The object parameter is the dispensed object. It can be null if the buffer's pull waiting time is limited and there are no objects in the buffer. The urgent parameter tells that the object was pushed to the bottom of the buffer because of its urgency, and therefore it should be handled accordingly. For instance if the dispensed objects are written to a communication socket, the socket should be flushed after writing urgent objects.

      Parameters:
      object - the object pulled from the associated buffer, or null if the buffer is empty.
      urgent - marks an urgent object.
    • handleException

      void handleException​(Exception ex)
      Handles an exception occurred while processing the associated ZBuffer object.

      Implement this method to handle exceptions in the associated buffer.

      Parameters:
      ex - the exception.