Skip to content

Commit

Permalink
Don't use _unsafeInheritExecutor in swift older than 5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
ktoso committed Apr 25, 2023
1 parent 8c4a4c3 commit b7aeba8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/InstrumentationBaggage/Baggage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,15 @@ extension Baggage {
/// To access the task-local value, use `Baggage.current`.
///
/// SeeAlso: [Swift Task Locals](https://developer.apple.com/documentation/swift/tasklocal)
#if swift(>=5.7)
@_unsafeInheritExecutor // same as withValue declared in the stdlib; because we do not want to hop off the executor at all
public static func withValue<T>(_ value: Baggage?, operation: () async throws -> T) async rethrows -> T {
try await Baggage.$current.withValue(value, operation: operation)
}
#else
public static func withValue<T>(_ value: Baggage?, operation: () async throws -> T) async rethrows -> T {
try await Baggage.$current.withValue(value, operation: operation)
}
#endif
}
#endif

0 comments on commit b7aeba8

Please sign in to comment.