Skip to content

Commit d2d8a38

Browse files
authored
Add @inlinable to ConnectionPool.run() (#552)
Previously the `ConnectionPool.run()` method wasn't marked as `@inlinable`, because of this we missed an opportunity to specialize the code that is run as part of the events.
1 parent f78b2e3 commit d2d8a38

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Sources/ConnectionPoolModule/ConnectionPool.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ public final class ConnectionPool<
271271
}
272272
}
273273

274+
@inlinable
274275
public func run() async {
275276
await withTaskCancellationHandler {
276277
if #available(macOS 14.0, iOS 17.0, tvOS 17.0, watchOS 10.0, *) {
@@ -312,13 +313,15 @@ public final class ConnectionPool<
312313
}
313314

314315
@available(macOS 14.0, iOS 17.0, tvOS 17.0, watchOS 10.0, *)
315-
private func run(in taskGroup: inout DiscardingTaskGroup) async {
316+
@inlinable
317+
/* private */ func run(in taskGroup: inout DiscardingTaskGroup) async {
316318
for await event in self.eventStream {
317319
self.runEvent(event, in: &taskGroup)
318320
}
319321
}
320322

321-
private func run(in taskGroup: inout TaskGroup<Void>) async {
323+
@inlinable
324+
/* private */ func run(in taskGroup: inout TaskGroup<Void>) async {
322325
var running = 0
323326
for await event in self.eventStream {
324327
running += 1
@@ -331,7 +334,8 @@ public final class ConnectionPool<
331334
}
332335
}
333336

334-
private func runEvent(_ event: NewPoolActions, in taskGroup: inout some TaskGroupProtocol) {
337+
@inlinable
338+
/* private */ func runEvent(_ event: NewPoolActions, in taskGroup: inout some TaskGroupProtocol) {
335339
switch event {
336340
case .makeConnection(let request):
337341
self.makeConnection(for: request, in: &taskGroup)

Sources/ConnectionPoolModule/PoolStateMachine.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ struct PoolStateMachine<
434434
fatalError("Unimplemented")
435435
}
436436

437+
@usableFromInline
437438
mutating func triggerForceShutdown() -> Action {
438439
switch self.poolState {
439440
case .running:

0 commit comments

Comments
 (0)