Interface Publisher<T>
- Type Parameters:
T
-
- All Known Subinterfaces:
AsyncPublisher<T>
- All Known Implementing Classes:
AbstractPublisher
,ConcurrentDequePublisher
,ConcurrentLockedPublisher
,LinkedPublisher
public interface Publisher<T>
Publishes events to multiple subscribers. This interface defines a simple synchronous style publisher/subscriber
system.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears allSubscription
s and implicitly removes them from the internal pool.void
Publishes the event synchronously.void
Publishes the supplied event synchronously and calls theConsumer
when allSubscription
s have been notified.void
Publishes the supplied event synchronously and calls theConsumer
when allSubscription
s have been notified.subscribe
(BiConsumer<Subscription, ? super T> consumer) Subscribes to a particular event.default Subscription
Subscribes to a particular event.
-
Method Details
-
subscribe
Subscribes to a particular event. The suppliedConsumer
will receive zero or more events in the future until the associated call toSubscription.unsubscribe()
.- Parameters:
consumer
- theConsumer
which will accept event- Returns:
- the
Subscription
-
subscribe
Subscribes to a particular event. The suppliedBiConsumer
will receive zero or more events in the future until the associated call toSubscription.unsubscribe()
.- Parameters:
consumer
- theBiConsumer
which will accept event- Returns:
- the
Subscription
-
clear
void clear()Clears allSubscription
s and implicitly removes them from the internal pool. Implementing this interface method is optional, and therefore this may throw an instance ofUnsupportedOperationException
. -
publish
Publishes the event synchronously.- Parameters:
t
- the event
-
publish
Publishes the supplied event synchronously and calls theConsumer
when allSubscription
s have been notified.- Parameters:
t
- the eventonFinish
- theConsumer
to be called after allSubscription
s have been notified
-
publish
Publishes the supplied event synchronously and calls theConsumer
when allSubscription
s have been notified. Additionally, this notifies for every exception thrown in the process.- Parameters:
t
- the eventonFinish
- theConsumer
to be called after allSubscription
s have been notifiedonException
- theConsumer
which is notified for each exception thrown
-