Static Methodswift-nio 2.72.0NIOPosix
_makePerpetualStartedPool(numberOfThreads:threadNamePrefix:)
Create a NIOThreadPool
that is already started, cannot be shut down and must not be deinit
ed.
static func _makePerpetualStartedPool(numberOfThreads: Int, threadNamePrefix: String) -> NIOThreadPool
This is only useful for global singletons.
Other members in extension
Types
enum WorkItemState
The state of the
WorkItem
.
Typealiases
typealias WorkItem
The work that should be done by the
NIOThreadPool
.
Type members
init(numberOfThreads: Int
) Initialize a
NIOThreadPool
thread pool withnumberOfThreads
threads.static var singleton: NIOThreadPool
A globally shared, singleton
NIOThreadPool
.
Instance members
let numberOfThreads: Int
func runIfActive<T>(@escaping () throws -> T
) async throws -> T Runs the submitted closure if the thread pool is still active, otherwise throw an error. The closure will be run on the thread pool so can do blocking work.
func runIfActive<T>(eventLoop: EventLoop, @escaping () throws -> T
) -> EventLoopFuture<T> Runs the submitted closure if the thread pool is still active, otherwise fails the promise. The closure will be run on the thread pool so can do blocking work.
func shutdownGracefully(
) async throws Shuts down the thread pool gracefully.
func shutdownGracefully(@escaping (Error?) -> Void
) func shutdownGracefully(queue: DispatchQueue, @escaping (Error?) -> Void
) Gracefully shutdown this
NIOThreadPool
. All tasks will be run before shutdown will take place.func start(
) Start the
NIOThreadPool
if not already started.func submit(@escaping WorkItem
) Submit a
WorkItem
to process.func syncShutdownGracefully(
) throws