public final class MultiThreadedEventLoopGroup : EventLoopGroup
The effect of initializing a
MultiThreadedEventLoopGroup is to spawn
numberOfThreads fresh threads which will
all run their own
EventLoop. Those threads will not be shut down until
syncShutdownGracefully is called.
NoteIt’s good style to call
MultiThreadedEventLoopGroup.syncShutdownGracefullywhen you no longer need this
EventLoopGroup. In many cases that is just before your program exits.
WarningUnit tests often spawn one
MultiThreadedEventLoopGroupper unit test to force isolation between the tests. In those cases it’s important to shut the
MultiThreadedEventLoopGroupdown at the end of the test. A good place to start a
setUpmethod of your
XCTestCasesubclass, a good place to shut it down is the
MultiThreadedEventLoopGroupinstance which uses
Don’t forget to call
syncShutdownGracefullywhen you no longer need this
EventLoopGroup. If you forget to shut the
EventLoopGroupdown you will leak
numberOfThreads(kernel) threads which are costly resources. This is especially important in unit tests where one
MultiThreadedEventLoopGroupis started per test case.
- numberOfThreads: The number of
public convenience init(numberOfThreads: Int)
MultiThreadedEventLoopGroupdown which causes the
EventLoops and their associated threads to be shut down and release their resources.
public func shutdownGracefully(queue: DispatchQueue, _ handler: @escaping (Error?) -> Void)
handleron when the shutdown operation completes.
The handler which is called after the shutdown operation completes. The parameter will be
nilon success and contain the