Class ChannelConsumers
ChannelConsumers.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> io.activej.promise.Promise<Void>acceptAll(ChannelConsumer<T> output, Iterator<? extends T> it) Passes iterator's values to theoutputuntil ithasNext(), then returns a promise ofnullas a marker of completion.static <T> io.activej.promise.Promise<Void>acceptAll(ChannelConsumer<T> output, List<? extends T> list) static OutputStreamchannelConsumerAsOutputStream(io.activej.eventloop.Eventloop eventloop, ChannelConsumer<io.activej.bytebuf.ByteBuf> channelConsumer) Creates anOutputStreamout of aChannelConsumer<io.activej.bytebuf.ByteBuf>.static ChannelConsumer<io.activej.bytebuf.ByteBuf>outputStreamAsChannelConsumer(Executor executor, OutputStream outputStream) Creates an asynchronousChannelConsumer<io.activej.bytebuf.ByteBuf>out of someOutputStream.static <T extends io.activej.common.recycle.Recyclable>
ChannelConsumer<T>
-
Constructor Details
-
ChannelConsumers
public ChannelConsumers()
-
-
Method Details
-
acceptAll
public static <T> io.activej.promise.Promise<Void> acceptAll(ChannelConsumer<T> output, Iterator<? extends T> it) Passes iterator's values to theoutputuntil ithasNext(), then returns a promise ofnullas a marker of completion.If there was an exception while accepting iterator, a promise of exception will be returned.
- Type Parameters:
T- a data type of passed values- Parameters:
output- aChannelConsumer, which accepts the iteratorit- anIteratorwhich provides some values- Returns:
- a promise of
nullas a marker of completion
-
acceptAll
public static <T> io.activej.promise.Promise<Void> acceptAll(ChannelConsumer<T> output, List<? extends T> list) -
recycling
-
outputStreamAsChannelConsumer
public static ChannelConsumer<io.activej.bytebuf.ByteBuf> outputStreamAsChannelConsumer(Executor executor, OutputStream outputStream) Creates an asynchronousChannelConsumer<io.activej.bytebuf.ByteBuf>out of someOutputStream.I/O operations are executed using a specified
Executor, so that the channel consumer operations does not block the eventloop thread.Passed
OutputStreamwill be closed once a resultingChannelConsumer<io.activej.bytebuf.ByteBuf>is closed or in case an error occurs during channel consumer operations.This method should be called from within eventloop thread
- Parameters:
executor- an executor that will execute blocking I/OoutputStream- anOutputStreamthat is transformed into aChannelConsumer<io.activej.bytebuf.ByteBuf>- Returns:
- a
ChannelConsumer<io.activej.bytebuf.ByteBuf>out ouf anOutputStream
-
channelConsumerAsOutputStream
public static OutputStream channelConsumerAsOutputStream(io.activej.eventloop.Eventloop eventloop, ChannelConsumer<io.activej.bytebuf.ByteBuf> channelConsumer) Creates anOutputStreamout of aChannelConsumer<io.activej.bytebuf.ByteBuf>.Asynchronous operations are executed in a context of a specified
EventloopPassed
ChannelSupplier<io.activej.bytebuf.ByteBuf>will be closed once a resultingOutputStreamis closed or in case an error occurs while reading data.OutputStream's methods are blocking, so they should not be called from an eventloop thread- Parameters:
eventloop- an eventloop that will execute asynchronous operationschannelConsumer- aChannelSupplier<io.activej.bytebuf.ByteBuf>that is transformed to anOutputStream- Returns:
- an
OutputStreamout ouf aChannelSupplier<io.activej.bytebuf.ByteBuf>
-