BusyCallback and BusyMode are Sendable

This commit is contained in:
Gwendal Roué committed 2024-07-27 16:37:32 +02:00
1 parent 04d8c357b5
commit e0d8e20bef
3 files changed
+9 -9

No files matched your search

+2 -2
View File
@@ -1831,7 +1831,7 @@ extension Database {
// MARK: - Database-Related Types
/// See BusyMode and <https://www.sqlite.org/c3ref/busy_handler.html>
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 {
/// - <https://www.sqlite.org/c3ref/busy_handler.html>
/// - <https://www.sqlite.org/lang_transaction.html>
/// - <https://www.sqlite.org/wal.html>
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
+1 -1
View File
@@ -111,7 +111,7 @@
- [ ] commontableexpression
- [ ] configuration
- [ ] customtransactionclock
- [ ] database/busymode
- [X] database/busymode
- [ ] databaseaggregate
- [ ] databasecancellable
- [ ] databasecollation
@@ -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)
}
}