-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Performance: new check to ensure serialization / deserialization is d…
…one from background thread (#2496)
- Loading branch information
Showing
4 changed files
with
61 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// Copyright RevenueCat Inc. All Rights Reserved. | ||
// | ||
// Licensed under the MIT License (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://opensource.org/licenses/MIT | ||
// | ||
// Assertions.swift | ||
// | ||
// Created by Nacho Soto on 5/16/23. | ||
|
||
import Foundation | ||
|
||
/// Equivalent to `assert`, but will only evaluate condition during RC tests. | ||
/// - Note: this is a no-op in release builds. | ||
@inline(__always) | ||
func RCTestAssert( | ||
_ condition: @autoclosure () -> Bool, | ||
_ message: @autoclosure () -> String, | ||
file: StaticString = #file, | ||
line: UInt = #line | ||
) { | ||
#if DEBUG | ||
guard ProcessInfo.isRunningRevenueCatTests else { return } | ||
|
||
precondition(condition(), message(), file: file, line: line) | ||
#endif | ||
} | ||
|
||
@inline(__always) | ||
func RCTestAssertNotMainThread( | ||
function: StaticString = #function, | ||
file: StaticString = #file, | ||
line: UInt = #line | ||
) { | ||
#if DEBUG | ||
RCTestAssert( | ||
!Thread.isMainThread, | ||
"\(function) should not be called from the main thread", | ||
file: file, | ||
line: line | ||
) | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters