Class ThreadedStreamConsumer
- java.lang.Object
-
- org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,EventHandler<Event>
public final class ThreadedStreamConsumer extends java.lang.Object implements EventHandler<Event>, java.io.Closeable
Knows how to reconstruct *all* the state transmitted over Channel by the forked process.
After applying the performance improvements withThreadedStreamConsumer.QueueSynchronizer
the throughput becomes 6.33 mega messages per second (158 nano seconds per message, 5 million messages within 0.79 seconds - see the test ThreadedStreamConsumerTest) on CPU i5 Dual Core 2.6 GHz and Oracle JDK 11.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ThreadedStreamConsumer.FinalEvent
(package private) class
ThreadedStreamConsumer.Pumper
(package private) static class
ThreadedStreamConsumer.QueueSynchronizer<T>
This synchronization helper mostly avoids the locks.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Thread
consumer
private static Event
END_ITEM
private java.util.concurrent.atomic.AtomicBoolean
isAlive
private ThreadedStreamConsumer.Pumper
pumper
private static int
QUEUE_MAX_ITEMS
private java.util.concurrent.atomic.AtomicBoolean
stop
private ThreadedStreamConsumer.QueueSynchronizer<Event>
synchronizer
-
Constructor Summary
Constructors Constructor Description ThreadedStreamConsumer(EventHandler<Event> target)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
handleEvent(Event event)
private static boolean
shouldStopQueueing(Event item)
Compared item withEND_ITEM
by identity.
-
-
-
Field Detail
-
QUEUE_MAX_ITEMS
private static final int QUEUE_MAX_ITEMS
- See Also:
- Constant Field Values
-
END_ITEM
private static final Event END_ITEM
-
synchronizer
private final ThreadedStreamConsumer.QueueSynchronizer<Event> synchronizer
-
stop
private final java.util.concurrent.atomic.AtomicBoolean stop
-
isAlive
private final java.util.concurrent.atomic.AtomicBoolean isAlive
-
consumer
private final java.lang.Thread consumer
-
pumper
private final ThreadedStreamConsumer.Pumper pumper
-
-
Constructor Detail
-
ThreadedStreamConsumer
public ThreadedStreamConsumer(EventHandler<Event> target)
-
-
Method Detail
-
handleEvent
public void handleEvent(@Nonnull Event event)
- Specified by:
handleEvent
in interfaceEventHandler<Event>
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-