WorkItemState
The state of the WorkItem.
enum WorkItemStateThe state of the WorkItem.
enum WorkItemStateimport NIOPosixPlatform-specific implementations of SwiftNIO abstractions for POSIX systems.
final class NIOThreadPoolA thread pool that should be used if some (kernel thread) blocking work needs to be performed for which no non-blocking API exists.
case activeThe WorkItem is active now and in process by the NIOThreadPool.
case cancelledThe WorkItem was cancelled and will not be processed by the NIOThreadPool.
convenience init(numberOfThreads: Int) Initialize a NIOThreadPool thread pool with numberOfThreads threads.
static var singleton: NIOThreadPool { get }A globally shared, singleton NIOThreadPool.
static func _makePerpetualStartedPool(numberOfThreads: Int, threadNamePrefix: String) -> NIOThreadPool Create a NIOThreadPool that is already started, cannot be shut down and must not be deinited.
let numberOfThreads: Intfunc _start(threadNamePrefix: String) func runIfActive<T>(_ body: @escaping () throws -> T) async throws -> T where T : Sendable Runs the submitted closure if the thread pool is still active, otherwise throw an error. The closure will be run on the thread pool, such that we can do blocking work.
@preconcurrency func runIfActive<T>(eventLoop: any EventLoop, _ body: @escaping () throws -> T) -> EventLoopFuture<T> where T : Sendable 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.
@preconcurrency func shutdownGracefully(_ callback: @escaping ((any Error)?) -> Void) @preconcurrency func shutdownGracefully(queue: DispatchQueue, _ callback: @escaping ((any 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.
@preconcurrency func submit(_ body: @escaping NIOThreadPool.WorkItem) Submit a WorkItem to process.
func syncShutdownGracefully() throws typealias WorkItem = (NIOThreadPool.WorkItemState) -> VoidThe work that should be done by the NIOThreadPool.
protocol EquatableA type that can be compared for value equality.
protocol Hashable : EquatableA type that can be hashed into a Hasher to produce an integer hash value.
protocol Sendable : SendableMetatypeA thread-safe type whose values can be shared across arbitrary concurrent contexts without introducing a risk of data races. Values of the type may have no shared mutable state, or they may protect that state with a lock or by forcing it to only be accessed from a specific actor.
protocol SendableMetatype : ~Copyable, ~EscapableA type whose metatype can be shared across arbitrary concurrent contexts without introducing a risk of data races. When a generic type T conforms to SendableMetatype, its metatype T.Type conforms to Sendable. All concrete types implicitly conform to the SendableMetatype protocol, so its primary purpose is in generic code to prohibit the use of isolated conformances along with the generic type.
static func != (lhs: Self, rhs: Self) -> Bool Returns a Boolean value indicating whether two values are not equal.