Object
ReplayablePublisher<T>
- Type Parameters:
T
- input type
- All Implemented Interfaces:
AutoCloseable
,Flow.Publisher<T>
Publisher which caches last N submitted items and replays them to new subscribers.
Items are replayed before the Flow.Subscriber.onSubscribe(java.util.concurrent.Flow.Subscription)
-
Constructor Summary
ConstructorDescriptionReplayablePublisher
(int cacheSize) ReplayablePublisher
(int cacheSize, Executor executor, int maxBufferCapacity) -
Method Summary
Modifier and TypeMethodDescriptionboolean
cacheContains
(T o) void
void
close()
int
boolean
boolean
isSubscribed
(Flow.Subscriber<? super T> subscriber) void
void
subscribe
(ReplayableSubscriber<? super T> subscriber) void
subscribe
(Flow.Subscriber<? super T> subscriber)
-
Constructor Details
-
ReplayablePublisher
public ReplayablePublisher(int cacheSize) -
ReplayablePublisher
-
-
Method Details
-
submit
-
subscribe
-
subscribe
- Specified by:
subscribe
in interfaceFlow.Publisher<T>
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
getNumberOfItemsInCache
public int getNumberOfItemsInCache() -
isCacheEmpty
public boolean isCacheEmpty() -
cacheContains
-
clearCache
public void clearCache() -
getCacheReadOnly
-
isSubscribed
-