Package dev.getelements.elements.rt
Interface AsyncConnectionPool<ContextT,SocketT>
- All Superinterfaces:
AutoCloseable
An interface to an underlying pool of sockets.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
acquireNextAvailableConnection
(Consumer<AsyncConnection<ContextT, SocketT>> asyncConnectionConsumer) Acquires a newAsyncConnection
.void
close()
Closes thisAsyncConnectionPool<ContextT,
and releases allSocketT> AsyncConnection<ContextT,
resources stored therein.SocketT>
-
Method Details
-
acquireNextAvailableConnection
void acquireNextAvailableConnection(Consumer<AsyncConnection<ContextT, SocketT>> asyncConnectionConsumer) Acquires a newAsyncConnection
. Once assigned to a thread, the suppliedConsumer
will be called by the IO Thread with an allocated instance ofAsyncConnection<ContextT,
. This method will block until anSocketT> AsyncConnection
is available.- Parameters:
asyncConnectionConsumer
- theConsumer
which will accept theAsyncConnection<ContextT,
SocketT>
-
close
void close()Closes thisAsyncConnectionPool<ContextT,
and releases allSocketT> AsyncConnection<ContextT,
resources stored therein. Safe to call from any thread.SocketT> - Specified by:
close
in interfaceAutoCloseable
-