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 TypeMethodDescriptionvoidclear()Clears allSubscriptions and implicitly removes them from the internal pool.voidPublishes the event synchronously.voidPublishes the supplied event synchronously and calls theConsumerwhen allSubscriptions have been notified.voidPublishes the supplied event synchronously and calls theConsumerwhen allSubscriptions have been notified.subscribe(BiConsumer<Subscription, ? super T> consumer) Subscribes to a particular event.default SubscriptionSubscribes to a particular event.
-
Method Details
-
subscribe
Subscribes to a particular event. The suppliedConsumerwill receive zero or more events in the future until the associated call toSubscription.unsubscribe().- Parameters:
consumer- theConsumerwhich will accept event- Returns:
- the
Subscription
-
subscribe
Subscribes to a particular event. The suppliedBiConsumerwill receive zero or more events in the future until the associated call toSubscription.unsubscribe().- Parameters:
consumer- theBiConsumerwhich will accept event- Returns:
- the
Subscription
-
clear
void clear()Clears allSubscriptions 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 theConsumerwhen allSubscriptions have been notified.- Parameters:
t- the eventonFinish- theConsumerto be called after allSubscriptions have been notified
-
publish
Publishes the supplied event synchronously and calls theConsumerwhen allSubscriptions have been notified. Additionally, this notifies for every exception thrown in the process.- Parameters:
t- the eventonFinish- theConsumerto be called after allSubscriptions have been notifiedonException- theConsumerwhich is notified for each exception thrown
-