Skip to content

Commit 27885d3

Browse files
committed
Test if allocs reduced
1 parent d532252 commit 27885d3

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"mallocCountTotal": 82000
2+
"mallocCountTotal" : 108
33
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"mallocCountTotal" : 164376
3-
}
2+
"mallocCountTotal" : 108
3+
}

Sources/NIOCore/AsyncSequences/NIOAsyncWriter.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ extension NIOAsyncWriter {
540540
let yieldID = yieldID ?? self._yieldIDGenerator.generateUniqueYieldID()
541541

542542
return try await withTaskCancellationHandler {
543-
// We are manually locking here to hold the lock across the withCheckedContinuation call
543+
// We are manually locking here to hold the lock across the withUnsafeContinuation call
544544
let unsafe = self._state.unsafe
545545
unsafe.lock()
546546

@@ -561,8 +561,8 @@ extension NIOAsyncWriter {
561561
throw error
562562

563563
case .suspendTask:
564-
return try await withCheckedThrowingContinuation {
565-
(continuation: CheckedContinuation<StateMachine.YieldResult, Error>) in
564+
return try await withUnsafeThrowingContinuation {
565+
(continuation: UnsafeContinuation<StateMachine.YieldResult, Error>) in
566566
let didSuspend = unsafe.withValueAssumingLockIsAcquired {
567567
$0.stateMachine.yield(continuation: continuation, yieldID: yieldID)
568568
return $0.didSuspend
@@ -611,7 +611,7 @@ extension NIOAsyncWriter {
611611
let yieldID = yieldID ?? self._yieldIDGenerator.generateUniqueYieldID()
612612

613613
return try await withTaskCancellationHandler {
614-
// We are manually locking here to hold the lock across the withCheckedContinuation call
614+
// We are manually locking here to hold the lock across the withUnsafeContinuation call
615615
let unsafe = self._state.unsafe
616616
unsafe.lock()
617617

@@ -632,8 +632,8 @@ extension NIOAsyncWriter {
632632
throw error
633633

634634
case .suspendTask:
635-
return try await withCheckedThrowingContinuation {
636-
(continuation: CheckedContinuation<StateMachine.YieldResult, Error>) in
635+
return try await withUnsafeThrowingContinuation {
636+
(continuation: UnsafeContinuation<StateMachine.YieldResult, Error>) in
637637
let didSuspend = unsafe.withValueAssumingLockIsAcquired {
638638
$0.stateMachine.yield(continuation: continuation, yieldID: yieldID)
639639
return $0.didSuspend
@@ -736,10 +736,10 @@ extension NIOAsyncWriter {
736736
/// The yield's produced sequence of elements.
737737
/// The yield's continuation.
738738
@usableFromInline
739-
var continuation: CheckedContinuation<YieldResult, Error>
739+
var continuation: UnsafeContinuation<YieldResult, Error>
740740

741741
@inlinable
742-
init(yieldID: YieldID, continuation: CheckedContinuation<YieldResult, Error>) {
742+
init(yieldID: YieldID, continuation: UnsafeContinuation<YieldResult, Error>) {
743743
self.yieldID = yieldID
744744
self.continuation = continuation
745745
}
@@ -1143,7 +1143,7 @@ extension NIOAsyncWriter {
11431143
/// This method is called as a result of the above `yield` method if it decided that the task needs to get suspended.
11441144
@inlinable
11451145
internal mutating func yield(
1146-
continuation: CheckedContinuation<YieldResult, Error>,
1146+
continuation: UnsafeContinuation<YieldResult, Error>,
11471147
yieldID: YieldID
11481148
) {
11491149
switch self._state {
@@ -1216,7 +1216,7 @@ extension NIOAsyncWriter {
12161216
@usableFromInline
12171217
enum CancelAction {
12181218
/// Indicates that the continuation should be resumed with a `CancellationError`.
1219-
case resumeContinuationWithCancellationError(CheckedContinuation<YieldResult, Error>)
1219+
case resumeContinuationWithCancellationError(UnsafeContinuation<YieldResult, Error>)
12201220
/// Indicates that nothing should be done.
12211221
case none
12221222
}

Sources/NIOCore/AsyncSequences/NIOThrowingAsyncSequenceProducer.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,8 @@ extension NIOThrowingAsyncSequenceProducer {
625625
case .suspendTask:
626626
// It is safe to hold the lock across this method
627627
// since the closure is guaranteed to be run straight away
628-
return try await withCheckedThrowingContinuation {
629-
(continuation: CheckedContinuation<Element?, any Error>) in
628+
return try await withUnsafeThrowingContinuation {
629+
(continuation: UnsafeContinuation<Element?, any Error>) in
630630
let (action, callDidSuspend) = unsafe.withValueAssumingLockIsAcquired {
631631
let action = $0.stateMachine.next(for: continuation)
632632
let callDidSuspend = $0.didSuspend != nil
@@ -723,7 +723,7 @@ extension NIOThrowingAsyncSequenceProducer {
723723
case streaming(
724724
backPressureStrategy: Strategy,
725725
buffer: Deque<Element>,
726-
continuation: CheckedContinuation<Element?, Error>?,
726+
continuation: UnsafeContinuation<Element?, Error>?,
727727
hasOutstandingDemand: Bool,
728728
iteratorInitialized: Bool
729729
)
@@ -916,13 +916,13 @@ extension NIOThrowingAsyncSequenceProducer {
916916
/// Indicates that the continuation should be resumed and
917917
/// ``NIOThrowingAsyncSequenceProducer/Source/YieldResult/produceMore`` should be returned.
918918
case resumeContinuationAndReturnProduceMore(
919-
continuation: CheckedContinuation<Element?, Error>,
919+
continuation: UnsafeContinuation<Element?, Error>,
920920
element: Element
921921
)
922922
/// Indicates that the continuation should be resumed and
923923
/// ``NIOThrowingAsyncSequenceProducer/Source/YieldResult/stopProducing`` should be returned.
924924
case resumeContinuationAndReturnStopProducing(
925-
continuation: CheckedContinuation<Element?, Error>,
925+
continuation: UnsafeContinuation<Element?, Error>,
926926
element: Element
927927
)
928928
/// Indicates that the yielded elements have been dropped.
@@ -931,7 +931,7 @@ extension NIOThrowingAsyncSequenceProducer {
931931
@usableFromInline
932932
init(
933933
shouldProduceMore: Bool,
934-
continuationAndElement: (CheckedContinuation<Element?, Error>, Element)? = nil
934+
continuationAndElement: (UnsafeContinuation<Element?, Error>, Element)? = nil
935935
) {
936936
switch (shouldProduceMore, continuationAndElement) {
937937
case (true, .none):
@@ -1040,7 +1040,7 @@ extension NIOThrowingAsyncSequenceProducer {
10401040
enum FinishAction {
10411041
/// Indicates that the continuation should be resumed with `nil` and
10421042
/// that ``NIOAsyncSequenceProducerDelegate/didTerminate()`` should be called.
1043-
case resumeContinuationWithFailureAndCallDidTerminate(CheckedContinuation<Element?, Error>, Failure?)
1043+
case resumeContinuationWithFailureAndCallDidTerminate(UnsafeContinuation<Element?, Error>, Failure?)
10441044
/// Indicates that nothing should be done.
10451045
case none
10461046
}
@@ -1094,7 +1094,7 @@ extension NIOThrowingAsyncSequenceProducer {
10941094
case callDidTerminate
10951095
/// Indicates that the continuation should be resumed with a `CancellationError` and
10961096
/// that ``NIOAsyncSequenceProducerDelegate/didTerminate()`` should be called.
1097-
case resumeContinuationWithCancellationErrorAndCallDidTerminate(CheckedContinuation<Element?, Error>)
1097+
case resumeContinuationWithCancellationErrorAndCallDidTerminate(UnsafeContinuation<Element?, Error>)
10981098
/// Indicates that nothing should be done.
10991099
case none
11001100
}
@@ -1273,7 +1273,7 @@ extension NIOThrowingAsyncSequenceProducer {
12731273
}
12741274

12751275
@inlinable
1276-
mutating func next(for continuation: CheckedContinuation<Element?, Error>) -> NextForContinuationAction {
1276+
mutating func next(for continuation: UnsafeContinuation<Element?, Error>) -> NextForContinuationAction {
12771277
switch self._state {
12781278
case .initial:
12791279
// We are transitioning away from the initial state in `next()`

0 commit comments

Comments
 (0)