Skip to content

Commit d8a0524

Browse files
committed
feat: Enable wasm compilation.
1 parent 6f3615c commit d8a0524

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

Package.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,30 @@ let package = Package(
1313
.library(name: "AsyncKit", targets: ["AsyncKit"]),
1414
],
1515
dependencies: [
16-
.package(url: "https://github.com/apple/swift-nio.git", from: "2.61.0"),
16+
.package(url: "https://github.com/apple/swift-nio.git", from: "2.89.0"),
1717
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.3"),
1818
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.5"),
1919
.package(url: "https://github.com/apple/swift-algorithms.git", from: "1.1.0"),
20+
.package(url: "https://github.com/PassiveLogic/swift-dispatch-async.git", from: "0.0.1"),
2021
],
2122
targets: [
2223
.target(
2324
name: "AsyncKit",
2425
dependencies: [
2526
.product(name: "Logging", package: "swift-log"),
2627
.product(name: "NIOCore", package: "swift-nio"),
27-
.product(name: "NIOEmbedded", package: "swift-nio"),
28-
.product(name: "NIOPosix", package: "swift-nio"),
2928
.product(name: "Collections", package: "swift-collections"),
3029
.product(name: "Algorithms", package: "swift-algorithms"),
30+
.product(name: "DispatchAsync", package: "swift-dispatch-async", condition: .when(platforms: [.wasi]))
3131
],
3232
swiftSettings: swiftSettings
3333
),
3434
.testTarget(
3535
name: "AsyncKitTests",
3636
dependencies: [
3737
.target(name: "AsyncKit"),
38+
.product(name: "NIOEmbedded", package: "swift-nio"),
39+
.product(name: "NIOPosix", package: "swift-nio"),
3840
],
3941
swiftSettings: swiftSettings
4042
),

Sources/AsyncKit/ConnectionPool/EventLoopGroupConnectionPool.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
#if canImport(Dispatch)
12
import Dispatch
3+
#elseif canImport(DispatchAsync)
4+
import DispatchAsync
5+
#endif
26
import NIOConcurrencyHelpers
37
import NIOCore
48
import struct Logging.Logger
@@ -280,6 +284,7 @@ public final class EventLoopGroupConnectionPool<Source> where Source: Connection
280284
}
281285
}
282286

287+
#if !os(WASI)
283288
/// Closes the connection pool.
284289
///
285290
/// All available connections will be closed immediately. Any connections still in use will be
@@ -312,6 +317,7 @@ public final class EventLoopGroupConnectionPool<Source> where Source: Connection
312317
}
313318
}
314319
}
320+
#endif // !os(WASI)
315321

316322
/// Closes the connection pool.
317323
///

Sources/AsyncKit/Exports.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
#if canImport(NIOEmbedded)
12
@_documentation(visibility: internal) @_exported import class NIOEmbedded.EmbeddedEventLoop
3+
#endif
24
@_documentation(visibility: internal) @_exported import protocol NIOCore.EventLoop
35
@_documentation(visibility: internal) @_exported import protocol NIOCore.EventLoopGroup
46
@_documentation(visibility: internal) @_exported import class NIOCore.EventLoopFuture
57
@_documentation(visibility: internal) @_exported import struct NIOCore.EventLoopPromise
8+
#if canImport(NIOPosix)
69
@_documentation(visibility: internal) @_exported import class NIOPosix.MultiThreadedEventLoopGroup
10+
#elseif canImport(NIOAsyncRuntime)
11+
@_documentation(visibility: internal) @_exported import class NIOAsyncRuntime.MultiThreadedEventLoopGroup
12+
#endif

Tests/AsyncKitTests/ConnectionPoolTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Logging
44
import NIOConcurrencyHelpers
55
import NIOCore
66
import NIOEmbedded
7+
import class NIOPosix.MultiThreadedEventLoopGroup
78
import XCTest
89

910
final class ConnectionPoolTests: AsyncKitTestCase {

0 commit comments

Comments
 (0)