Browse Source

Save an allocation in BufferedStream (#1991)

Gustavo Cairo 1 year ago
parent
commit
899c121827
1 changed files with 2 additions and 4 deletions
  1. 2 4
      Sources/GRPCCore/Streaming/Internal/BufferedStream.swift

+ 2 - 4
Sources/GRPCCore/Streaming/Internal/BufferedStream.swift

@@ -635,16 +635,14 @@ extension BufferedStream {
 
 @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
 extension BufferedStream {
-  // We are unchecked Sendable since we are protecting our state with a lock.
   @usableFromInline
-  final class _BackPressuredStorage: Sendable {
-    /// The state machine
+  struct _BackPressuredStorage: Sendable {
     @usableFromInline
     let _stateMachine: _ManagedCriticalState<_StateMachine>
 
     @usableFromInline
     var onTermination: (@Sendable () -> Void)? {
-      set {
+      nonmutating set {
         self._stateMachine.withCriticalRegion {
           $0._onTermination = newValue
         }