Guest User

Untitled

a guest
Jul 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. package org.reactivestreams;
  2.  
  3. /**
  4. * A {@link Subscription} represents a one-to-one lifecycle of a {@link Subscriber} subscribing to a {@link Publisher}.
  5. * <p>
  6. * It can only be used once by a single {@link Subscriber}.
  7. * <p>
  8. * It is used to both signal desire for data and cancel demand (and allow resource cleanup).
  9. *
  10. */
  11. public interface Subscription {
  12. /**
  13. * No events will be sent by a {@link Publisher} until demand is signaled via this method.
  14. * <p>
  15. * It can be called however often and whenever needed—but the outstanding cumulative demand must never exceed Long.MAX_VALUE.
  16. * An outstanding cumulative demand of Long.MAX_VALUE may be treated by the {@link Publisher} as "effectively unbounded".
  17. * <p>
  18. * Whatever has been requested can be sent by the {@link Publisher} so only signal demand for what can be safely handled.
  19. * <p>
  20. * A {@link Publisher} can send less than is requested if the stream ends but
  21. * then must emit either {@link Subscriber#onError(Throwable)} or {@link Subscriber#onComplete()}.
  22. *
  23. * @param n the strictly positive number of elements to requests to the upstream {@link Publisher}
  24. */
  25. public void request(long n);
  26.  
  27. /**
  28. * Request the {@link Publisher} to stop sending data and clean up resources.
  29. * <p>
  30. * Data may still be sent to meet previously signalled demand after calling cancel.
  31. */
  32. public void cancel();
  33. }
Add Comment
Please, Sign In to add comment