Skip to content

Commit

Permalink
Merge pull request #25 from pbk20191/develop
Browse files Browse the repository at this point in the history
fix NSPersistentStore crash with mutiple NSPersistentStoreDescription
  • Loading branch information
pbk20191 authored Mar 26, 2023
2 parents 49a4083 + 60b519a commit 1f697bc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 77 deletions.
13 changes: 0 additions & 13 deletions Sources/Tetra/Concurrency/CoreDataStack+Concurrency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@ import CoreData
@available(iOS 13.0, tvOS 13.0, macCatalyst 13.0, watchOS 6.0, macOS 10.15, *)
public extension NSPersistentContainer {

@inlinable
func loadPersistent() async throws -> NSPersistentStoreDescription {
try await withUnsafeThrowingContinuation { continuation in
loadPersistentStores {
if let error = $1 {
continuation.resume(throwing: error)
} else {
continuation.resume(returning: $0)
}
}
}
}

@available(iOS, introduced: 13.0, deprecated: 15.0, renamed: "performBackgroundTask(_:)")
@available(tvOS, introduced: 13.0, deprecated: 15.0, renamed: "performBackgroundTask(_:)")
@available(macCatalyst, introduced: 13.0, deprecated: 15.0, renamed: "performBackgroundTask(_:)")
Expand Down
1 change: 0 additions & 1 deletion Sources/Tetra/Concurrency/Dispatch+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public extension Task where Success == Never, Failure == Never {
*/
@inlinable
static func sleep(until wallDeadline:DispatchWallTime, tolerance:DispatchTimeInterval? = nil) async throws {
try await Task.sleep(nanoseconds: 1000)
try await dispatchTimerSleep(wait: wallDeadline, leeway: tolerance)
}

Expand Down
59 changes: 0 additions & 59 deletions Sources/Tetra/Foundation/Codable/DecodingTypeError.swift

This file was deleted.

14 changes: 10 additions & 4 deletions Tests/TetraTests/RunLoopSchedulerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final class RunLoopSchedulerTests: XCTestCase {
let scheduler = await RunLoopScheduler(async: (), config: .init(qos: .background))
let name = Notification.Name(UUID().uuidString)
let object = NSObject()
expectation(forNotification: name, object: object, notificationCenter: .default) { notification in
let expect1 = expectation(forNotification: name, object: object, notificationCenter: .default) { notification in
XCTAssertTrue(notification.userInfo?["A"] as? String == "B")
return true
}
Expand All @@ -63,8 +63,11 @@ final class RunLoopSchedulerTests: XCTestCase {

}
}
await waitForExpectations(timeout: 1)
expectation(forNotification: name, object: object, notificationCenter: .default) {
await withUnsafeContinuation{
wait(for: [expect1], timeout: 1)
$0.resume()
}
let expect2 = expectation(forNotification: name, object: object, notificationCenter: .default) {
XCTAssertTrue($0.userInfo?["A"] as? String == "C")
return true
}
Expand All @@ -75,7 +78,10 @@ final class RunLoopSchedulerTests: XCTestCase {
continuation.resume()
}
}
await waitForExpectations(timeout: 1)
await withUnsafeContinuation{
wait(for: [expect2], timeout: 1)
$0.resume()
}
}

}

0 comments on commit 1f697bc

Please sign in to comment.