diff --git a/GRDB/Core/Database.swift b/GRDB/Core/Database.swift index cf127412e..40a49554a 100644 --- a/GRDB/Core/Database.swift +++ b/GRDB/Core/Database.swift @@ -1829,7 +1829,7 @@ extension Database { // MARK: - Database-Related Types /// See BusyMode and - public typealias BusyCallback = (_ numberOfTries: Int) -> Bool + public typealias BusyCallback = @Sendable (_ numberOfTries: Int) -> Bool /// When there are several connections to a database, a connection may try /// to access the database while it is locked by another connection. @@ -1857,7 +1857,7 @@ extension Database { /// - /// - /// - - public enum BusyMode { + public enum BusyMode: Sendable { /// The `SQLITE_BUSY` error is immediately returned to the connection /// that tries to access the locked database. case immediateError diff --git a/TODO.md b/TODO.md index 1db61fe4f..f63334e8e 100644 --- a/TODO.md +++ b/TODO.md @@ -110,7 +110,7 @@ - [ ] commontableexpression - [ ] configuration - [ ] customtransactionclock - - [ ] database/busymode + - [X] database/busymode - [ ] databaseaggregate - [ ] databasecancellable - [ ] databasecollation diff --git a/Tests/GRDBTests/DatabaseQueueConcurrencyTests.swift b/Tests/GRDBTests/DatabaseQueueConcurrencyTests.swift index 613d6b5ad..1505e18bb 100644 --- a/Tests/GRDBTests/DatabaseQueueConcurrencyTests.swift +++ b/Tests/GRDBTests/DatabaseQueueConcurrencyTests.swift @@ -244,9 +244,9 @@ class ConcurrencyTests: GRDBTestCase { // BEGIN EXCLUSIVE TRANSACTION // COMMIT - var busyCallbackCalled = false + let busyCallbackCalled = Mutex(false) self.busyCallback = { n in - busyCallbackCalled = true + busyCallbackCalled.value = true s2.signal() return true } @@ -283,7 +283,7 @@ class ConcurrencyTests: GRDBTestCase { _ = group.wait(timeout: .distantFuture) - XCTAssertTrue(busyCallbackCalled) + XCTAssertTrue(busyCallbackCalled.value) } func testReaderDuringDefaultTransaction() throws { @@ -384,9 +384,9 @@ class ConcurrencyTests: GRDBTestCase { // COMMIT // COMMIT - var busyCallbackCalled = false + let busyCallbackCalled = Mutex(false) self.busyCallback = { n in - busyCallbackCalled = true + busyCallbackCalled.value = true s3.signal() return true } @@ -431,6 +431,6 @@ class ConcurrencyTests: GRDBTestCase { _ = group.wait(timeout: .distantFuture) - XCTAssertTrue(busyCallbackCalled) + XCTAssertTrue(busyCallbackCalled.value) } }