Class TimeoutBlockingWaitStrategy
java.lang.Object
org.apache.logging.log4j.core.async.TimeoutBlockingWaitStrategy
- All Implemented Interfaces:
com.lmax.disruptor.WaitStrategy
Blocking strategy that uses a lock and condition variable for
s waiting on a barrier.
However, it will periodically wake up if it has been idle for specified period by throwing a
, which the
will call if the timeout occurs.
invalid reference
EventProcessor
TimeoutException
. To make use of this, the event handler class should override
invalid reference
EventHandler#onTimeout(long)
invalid reference
BatchEventProcessor
This strategy can be used when throughput and low-latency are not as important as CPU resource.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Object
private static final int
private final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static long
awaitNanos
(Object mutex, long timeoutNanos) void
toString()
long
waitFor
(long sequence, com.lmax.disruptor.Sequence cursorSequence, com.lmax.disruptor.Sequence dependentSequence, com.lmax.disruptor.SequenceBarrier barrier)
-
Field Details
-
mutex
-
timeoutInNanos
private final long timeoutInNanos -
ONE_MILLISECOND_IN_NANOSECONDS
private static final int ONE_MILLISECOND_IN_NANOSECONDS- See Also:
-
-
Constructor Details
-
TimeoutBlockingWaitStrategy
- Parameters:
timeout
- how long to wait before waking upunits
- the unit in which timeout is specified
-
-
Method Details
-
waitFor
public long waitFor(long sequence, com.lmax.disruptor.Sequence cursorSequence, com.lmax.disruptor.Sequence dependentSequence, com.lmax.disruptor.SequenceBarrier barrier) throws com.lmax.disruptor.AlertException, InterruptedException, com.lmax.disruptor.TimeoutException - Specified by:
waitFor
in interfacecom.lmax.disruptor.WaitStrategy
- Throws:
com.lmax.disruptor.AlertException
InterruptedException
com.lmax.disruptor.TimeoutException
-
signalAllWhenBlocking
public void signalAllWhenBlocking()- Specified by:
signalAllWhenBlocking
in interfacecom.lmax.disruptor.WaitStrategy
-
toString
-
awaitNanos
- Parameters:
mutex
- The object to wait ontimeoutNanos
- The number of nanoseconds to wait for- Returns:
- the number of nanoseconds waited (approximately)
- Throws:
InterruptedException
- if the underlying call to wait is interrupted
-