diff --git a/GRDB/Core/Database.swift b/GRDB/Core/Database.swift index 3fb55e600..8cc9d3097 100644 --- a/GRDB/Core/Database.swift +++ b/GRDB/Core/Database.swift @@ -1831,7 +1831,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. @@ -1859,7 +1859,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 3ad01c3eb..4ff1b0d39 100644 --- a/TODO.md +++ b/TODO.md @@ -111,7 +111,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) } }