Package dev.getelements.elements.rt
Interface AsyncConnectionPool<ContextT,SocketT>
- All Superinterfaces:
AutoCloseable
An interface to an underlying pool of sockets.
-
Method Summary
Modifier and TypeMethodDescriptionvoidacquireNextAvailableConnection(Consumer<AsyncConnection<ContextT, SocketT>> asyncConnectionConsumer) Acquires a newAsyncConnection.voidclose()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 suppliedConsumerwill be called by the IO Thread with an allocated instance ofAsyncConnection<ContextT,. This method will block until anSocketT> AsyncConnectionis available.- Parameters:
asyncConnectionConsumer- theConsumerwhich 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:
closein interfaceAutoCloseable
-