Skip to content

Commit

Permalink
Merge pull request apple#72 from guoye-zhang/internal
Browse files Browse the repository at this point in the history
Remove usable from inline and internal properties
  • Loading branch information
guoye-zhang authored Nov 13, 2024
2 parents 7e038be + 51e4fd8 commit ef18d82
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 65 deletions.
49 changes: 0 additions & 49 deletions Sources/HTTPTypes/HTTPFieldName.swift
Original file line number Diff line number Diff line change
Expand Up @@ -557,53 +557,4 @@ extension HTTPField.Name {
public static var xContentTypeOptions: Self {
.init(rawName: "X-Content-Type-Options", canonicalName: "x-content-type-options")
}

// Deprecated
/// P3P
static var p3P: Self { .init(rawName: "P3P", canonicalName: "p3p") }
/// Pragma
static var pragma: Self { .init(rawName: "Pragma", canonicalName: "pragma") }
/// Timing-Allow-Origin
static var timingAllowOrigin: Self { .init(rawName: "Timing-Allow-Origin", canonicalName: "timing-allow-origin") }
/// X-Frame-Options
static var xFrameOptions: Self { .init(rawName: "X-Frame-Options", canonicalName: "x-frame-options") }
/// X-XSS-Protection
static var xXSSProtection: Self { .init(rawName: "X-XSS-Protection", canonicalName: "x-xss-protection") }
// Internal
/// Alt-Svc
static var altSvc: Self { .init(rawName: "Alt-Svc", canonicalName: "alt-svc") }
/// Keep-Alive
static var keepAlive: Self { .init(rawName: "Keep-Alive", canonicalName: "keep-alive") }
/// Proxy-Connection
static var proxyConnection: Self { .init(rawName: "Proxy-Connection", canonicalName: "proxy-connection") }
/// Upgrade-Insecure-Requests
static var upgradeInsecureRequests: Self {
.init(rawName: "Upgrade-Insecure-Requests", canonicalName: "upgrade-insecure-requests")
}
/// Datagram-Flow-Id
static var datagramFlowId: Self { .init(rawName: "Datagram-Flow-Id", canonicalName: "datagram-flow-id") }
/// Capsule-Protocol
static var capsuleProtocol: Self { .init(rawName: "Capsule-Protocol", canonicalName: "capsule-protocol") }
/// Server-Connection-Id
static var serverConnectionId: Self {
.init(rawName: "Server-Connection-Id", canonicalName: "server-connection-id")
}
/// Client-Connection-Id
static var clientConnectionId: Self {
.init(rawName: "Client-Connection-Id", canonicalName: "client-connection-id")
}
/// Sec-CH-Background
static var secCHBackground: Self { .init(rawName: "Sec-CH-Background", canonicalName: "sec-ch-background") }
/// Sec-CH-Geohash
static var secCHGeohash: Self { .init(rawName: "Sec-CH-Geohash", canonicalName: "sec-ch-geohash") }
/// Client-Geohash
static var clientGeohash: Self { .init(rawName: "Client-Geohash", canonicalName: "client-geohash") }
/// Proxy-QUIC-Forwarding
static var proxyQUICForwarding: Self {
.init(rawName: "Proxy-QUIC-Forwarding", canonicalName: "proxy-quic-forwarding")
}
/// Proxy-Config-Epoch
static var proxyConfigEpoch: Self { .init(rawName: "Proxy-Config-Epoch", canonicalName: "proxy-config-epoch") }
/// Connect-UDP-Bind
static var connectUDPBind: Self { .init(rawName: "Connect-UDP-Bind", canonicalName: "connect-udp-bind") }
}
16 changes: 0 additions & 16 deletions Sources/HTTPTypes/NIOLock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,16 @@ import wasi_pthread
#endif

#if os(Windows)
@usableFromInline
typealias LockPrimitive = SRWLOCK
#elseif canImport(Darwin)
@usableFromInline
typealias LockPrimitive = os_unfair_lock
#else
@usableFromInline
typealias LockPrimitive = pthread_mutex_t
#endif

@usableFromInline
enum LockOperations {}

extension LockOperations {
@inlinable
static func create(_ mutex: UnsafeMutablePointer<LockPrimitive>) {
mutex.assertValidAlignment()

Expand All @@ -77,7 +72,6 @@ extension LockOperations {
#endif
}

@inlinable
static func destroy(_ mutex: UnsafeMutablePointer<LockPrimitive>) {
mutex.assertValidAlignment()

Expand All @@ -91,7 +85,6 @@ extension LockOperations {
#endif
}

@inlinable
static func lock(_ mutex: UnsafeMutablePointer<LockPrimitive>) {
mutex.assertValidAlignment()

Expand All @@ -105,7 +98,6 @@ extension LockOperations {
#endif
}

@inlinable
static func unlock(_ mutex: UnsafeMutablePointer<LockPrimitive>) {
mutex.assertValidAlignment()

Expand Down Expand Up @@ -148,10 +140,8 @@ extension LockOperations {
// and future maintainers will be happier that we were cautious.
//
// See also: https://github.com/apple/swift/pull/40000
@usableFromInline
final class LockStorage<Value>: ManagedBuffer<Value, LockPrimitive> {

@inlinable
static func create(value: Value) -> Self {
let buffer = Self.create(minimumCapacity: 1) { _ in
value
Expand All @@ -168,35 +158,30 @@ final class LockStorage<Value>: ManagedBuffer<Value, LockPrimitive> {
return storage
}

@inlinable
func lock() {
self.withUnsafeMutablePointerToElements { lockPtr in
LockOperations.lock(lockPtr)
}
}

@inlinable
func unlock() {
self.withUnsafeMutablePointerToElements { lockPtr in
LockOperations.unlock(lockPtr)
}
}

@inlinable
deinit {
self.withUnsafeMutablePointerToElements { lockPtr in
LockOperations.destroy(lockPtr)
}
}

@inlinable
func withLockPrimitive<T>(_ body: (UnsafeMutablePointer<LockPrimitive>) throws -> T) rethrows -> T {
try self.withUnsafeMutablePointerToElements { lockPtr in
try body(lockPtr)
}
}

@inlinable
func withLockedValue<T>(_ mutate: (inout Value) throws -> T) rethrows -> T {
try self.withUnsafeMutablePointers { valuePtr, lockPtr in
LockOperations.lock(lockPtr)
Expand All @@ -209,7 +194,6 @@ final class LockStorage<Value>: ManagedBuffer<Value, LockPrimitive> {
extension LockStorage: @unchecked Sendable {}

extension UnsafeMutablePointer {
@inlinable
func assertValidAlignment() {
assert(UInt(bitPattern: self) % UInt(MemoryLayout<Pointee>.alignment) == 0)
}
Expand Down

0 comments on commit ef18d82

Please sign in to comment.