In NIO 2.21.0 a new enum EventLoopGroupProvider was introduced for easy passing around of EventLoopGroups in third party libraries.
This has been a great tool in lots of places, but still leaves the following code in nearly all client-libraries:
let eventLoopGroup: EventLoopGroup
switch eventLoopGroupProvider {
case .shared(let elg): eventLoopGroup = elg
case .createNew: eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
}
or something very similar. And along with this "setup" code almost all these blocks also come with a similar switch statement to shut down the ELG when .createNew or pass over when .shared()
I would like to propose one new method and one new property to be added to EventLoopGroupProvider.
First off EventLoopGroupProvider.eventLoopGroup that would return the EventLoopGroup in a one-liner, using the above switch statement internally.
Second off EventLoopGroupProvider.syncShutDownIfNotShared to shut down the ELG in case it's been newly created.
Curious to hear your input on if this has a place within NIO, or should stay in third-party libraries. Thanks!
In NIO 2.21.0 a new enum
EventLoopGroupProviderwas introduced for easy passing around of EventLoopGroups in third party libraries.This has been a great tool in lots of places, but still leaves the following code in nearly all client-libraries:
or something very similar. And along with this "setup" code almost all these blocks also come with a similar switch statement to shut down the ELG when
.createNewor pass over when.shared()I would like to propose one new method and one new property to be added to
EventLoopGroupProvider.First off
EventLoopGroupProvider.eventLoopGroupthat would return theEventLoopGroupin a one-liner, using the above switch statement internally.Second off
EventLoopGroupProvider.syncShutDownIfNotSharedto shut down the ELG in case it's been newly created.Curious to hear your input on if this has a place within NIO, or should stay in third-party libraries. Thanks!