mirror of
https://github.com/apple/swift-nio
synced 2026-11-25 04:47:49 +00:00
Guard autoreleasepool with canImport(ObjectiveC) (#3782)
The `autoreleasepool` code only needs the `ObjectiveC` runtime, not `Darwin`.
This commit is contained in:
1 parent
02d6d9ada2
commit
b440f7bae8
1 file changed
+5
-1
@@ -22,6 +22,10 @@ import NIOConcurrencyHelpers
|
||||
import NIOCore
|
||||
import _NIODataStructures
|
||||
|
||||
#if canImport(ObjectiveC)
|
||||
import ObjectiveC
|
||||
#endif
|
||||
|
||||
private func printError(_ string: StaticString) {
|
||||
string.withUTF8Buffer { buf in
|
||||
var buf = buf
|
||||
@@ -41,7 +45,7 @@ private func printError(_ string: StaticString) {
|
||||
/// Execute the given closure and ensure we release all auto pools if needed.
|
||||
@inlinable
|
||||
internal func withAutoReleasePool<T>(_ execute: () throws -> T) rethrows -> T {
|
||||
#if canImport(Darwin)
|
||||
#if canImport(ObjectiveC)
|
||||
return try autoreleasepool {
|
||||
try execute()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user