Merge pull request #72 from guoye-zhang/internal

Remove usable from inline and internal properties
This commit is contained in:
Guoye Zhang authored and GitHub committed 2024-11-13 15:35:29 +00:00
commit ef18d829e8
2 files changed
-65

No files matched your search

-49
View File
@@ -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
View File
@@ -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()
@@ -77,7 +72,6 @@ extension LockOperations {
#endif
}
@inlinable
static func destroy(_ mutex: UnsafeMutablePointer<LockPrimitive>) {
mutex.assertValidAlignment()
@@ -91,7 +85,6 @@ extension LockOperations {
#endif
}
@inlinable
static func lock(_ mutex: UnsafeMutablePointer<LockPrimitive>) {
mutex.assertValidAlignment()
@@ -105,7 +98,6 @@ extension LockOperations {
#endif
}
@inlinable
static func unlock(_ mutex: UnsafeMutablePointer<LockPrimitive>) {
mutex.assertValidAlignment()
@@ -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
@@ -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)
@@ -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)
}