From 4ba4e72b06f2dda5125bc4dce2c7d56e15ff62b0 Mon Sep 17 00:00:00 2001 From: Guoye Zhang Date: Wed, 23 Oct 2024 12:21:05 -0700 Subject: [PATCH] Remove the public class --- Sources/HTTPTypes/NIOLock.swift | 68 --------------------------------- 1 file changed, 68 deletions(-) diff --git a/Sources/HTTPTypes/NIOLock.swift b/Sources/HTTPTypes/NIOLock.swift index 9608d2d..b670565 100644 --- a/Sources/HTTPTypes/NIOLock.swift +++ b/Sources/HTTPTypes/NIOLock.swift @@ -195,74 +195,6 @@ final class LockStorage: ManagedBuffer { extension LockStorage: @unchecked Sendable {} -/// A threading lock based on `libpthread` instead of `libdispatch`. -/// -/// - note: ``NIOLock`` has reference semantics. -/// -/// This object provides a lock on top of a single `pthread_mutex_t`. This kind -/// of lock is safe to use with `libpthread`-based threading models, such as the -/// one used by NIO. On Windows, the lock is based on the substantially similar -/// `SRWLOCK` type. -public struct NIOLock { - @usableFromInline - internal let _storage: LockStorage - - /// Create a new lock. - @inlinable - public init() { - self._storage = .create(value: ()) - } - - /// Acquire the lock. - /// - /// Whenever possible, consider using `withLock` instead of this method and - /// `unlock`, to simplify lock handling. - @inlinable - public func lock() { - self._storage.lock() - } - - /// Release the lock. - /// - /// Whenever possible, consider using `withLock` instead of this method and - /// `lock`, to simplify lock handling. - @inlinable - public func unlock() { - self._storage.unlock() - } - - @inlinable - internal func withLockPrimitive(_ body: (UnsafeMutablePointer) throws -> T) rethrows -> T { - try self._storage.withLockPrimitive(body) - } -} - -extension NIOLock { - /// Acquire the lock for the duration of the given block. - /// - /// This convenience method should be preferred to `lock` and `unlock` in - /// most situations, as it ensures that the lock will be released regardless - /// of how `body` exits. - /// - /// - Parameter body: The block to execute while holding the lock. - /// - Returns: The value returned by the block. - @inlinable - public func withLock(_ body: () throws -> T) rethrows -> T { - self.lock() - defer { - self.unlock() - } - return try body() - } - - @inlinable - public func withLockVoid(_ body: () throws -> Void) rethrows { - try self.withLock(body) - } -} - -extension NIOLock: Sendable {} - extension UnsafeMutablePointer { @inlinable func assertValidAlignment() {