public class EmptySink extends Object implements Publisher<Void>, LockHandle
Sinks.Empty-like implementation
Very often, we busy-loop to deal with Sinks.EmitResult#FAIL_NON_SERIALIZED when
using Sinks. It may not be ideal and might lead to erroneous behaviours.
Instead, this implementation aims to rid these failures (by internally using an atomic field,
which still busy-loops to AtomicIntegerFieldUpdater.getAndUpdate(Object, IntUnaryOperator)
but is much simpler), while still providing necessary functionalities needed by lock implementations.
It expects:
LockHandle.CancellableHandle| Constructor and Description |
|---|
EmptySink() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancel()
Tries to emit a
LockCancellationException to a subscriber |
boolean |
emit()
Tries to emit
SignalType.ON_COMPLETE signal to a subscriber |
Mono<Void> |
mono()
Returns a
Mono that emits success only after acquiring the lock |
void |
subscribe(Subscriber<? super Void> s) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitempty, frompublic void subscribe(Subscriber<? super Void> s)
public boolean emit()
SignalType.ON_COMPLETE signal to a subscriber
It remembers the emission request if there is no subscriber, and emits the signal to the next subscriber instead.
true if successfully scheduled or emitted to the subscriberpublic boolean cancel()
LockCancellationException to a subscriber
It remembers the cancellation request if there is no subscriber, and emits the exception to the next subscriber instead.
cancel in interface LockHandletrue if successfully scheduled or emitted to the subscriberpublic Mono<Void> mono()
LockHandleMono that emits success only after acquiring the lockmono in interface LockHandleMono that emits success only after acquiring the lock