mirror of
https://github.com/apple/swift-nio
synced 2026-11-30 05:28:44 +00:00
Use NIOThreadPool in NIOFileSystem (#2692)
Motivation: There are two thread pools: one in NIOFileSystem and one in NIOPosix; we should avoid the duplication. Modifications: - Switch to using NIOThreadPool - Remove the old thread pool and associated code - Add an init to FileSystem which takes a thread pool Result: Less duplication
This commit is contained in:
1 parent
6b29fc3c2b
commit
2d840c586f
11 files changed
+145
-1054
No files matched your search
@@ -14,6 +14,7 @@
|
||||
|
||||
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android)
|
||||
import NIOCore
|
||||
import NIOPosix
|
||||
@_spi(Testing) import _NIOFileSystem
|
||||
import NIOFoundationCompat
|
||||
import XCTest
|
||||
@@ -83,24 +84,24 @@ final class FileHandleTests: XCTestCase {
|
||||
options: options,
|
||||
permissions: permissions
|
||||
)
|
||||
let executor = await IOExecutor.running(numberOfThreads: 1)
|
||||
let handle = SystemFileHandle(takingOwnershipOf: descriptor, path: path, executor: executor)
|
||||
let handle = SystemFileHandle(
|
||||
takingOwnershipOf: descriptor,
|
||||
path: path,
|
||||
threadPool: .singleton
|
||||
)
|
||||
|
||||
do {
|
||||
try await execute(handle)
|
||||
if autoClose {
|
||||
try? await handle.close()
|
||||
}
|
||||
await executor.drain()
|
||||
} catch let skip as XCTSkip {
|
||||
try? await handle.close()
|
||||
await executor.drain()
|
||||
throw skip
|
||||
} catch {
|
||||
XCTFail("Test threw error: '\(error)'")
|
||||
// Always close on error.
|
||||
try await handle.close()
|
||||
await executor.drain()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user