@@ -352,17 +352,13 @@ extension DatabasePool: DatabaseReader {
352352 }
353353
354354 public func read< T: Sendable > (
355- _ value: sending @escaping ( Database ) throws -> T
355+ _ value: @escaping @ Sendable ( Database) throws -> T
356356 ) async throws -> T {
357357 GRDBPrecondition ( currentReader == nil , " Database methods are not reentrant. " )
358358 guard let readerPool else {
359359 throw DatabaseError . connectionIsClosed ( )
360360 }
361361
362- // Avoid compiler warning. There is no data race because `value` is invoked once.
363- typealias SendableClosure = @Sendable ( Database) throws -> T
364- let value = unsafeBitCast ( value, to: SendableClosure . self)
365-
366362 let dbAccess = CancellableDatabaseAccess ( )
367363 return try await dbAccess. withCancellableContinuation { continuation in
368364 readerPool. asyncGet { result in
@@ -394,17 +390,13 @@ extension DatabasePool: DatabaseReader {
394390 }
395391
396392 public func asyncRead(
397- _ value: sending @escaping ( Result < Database , Error > ) -> Void
393+ _ value: @escaping @ Sendable ( Result < Database , Error > ) -> Void
398394 ) {
399395 guard let readerPool else {
400396 value ( . failure( DatabaseError . connectionIsClosed ( ) ) )
401397 return
402398 }
403399
404- // Avoid compiler warning. There is no data race because `value` is invoked once.
405- typealias SendableClosure = @Sendable ( Result < Database , Error > ) -> Void
406- let value = unsafeBitCast ( value, to: SendableClosure . self)
407-
408400 readerPool. asyncGet { result in
409401 do {
410402 let ( reader, releaseReader) = try result. get ( )
@@ -444,16 +436,12 @@ extension DatabasePool: DatabaseReader {
444436 }
445437
446438 public func unsafeRead< T: Sendable > (
447- _ value: sending @escaping ( Database ) throws -> T
439+ _ value: @escaping @ Sendable ( Database) throws -> T
448440 ) async throws -> T {
449441 guard let readerPool else {
450442 throw DatabaseError . connectionIsClosed ( )
451443 }
452444
453- // Avoid compiler warning. There is no data race because `value` is invoked once.
454- typealias SendableClosure = @Sendable ( Database) throws -> T
455- let value = unsafeBitCast ( value, to: SendableClosure . self)
456-
457445 let dbAccess = CancellableDatabaseAccess ( )
458446 return try await dbAccess. withCancellableContinuation { continuation in
459447 readerPool. asyncGet { result in
@@ -482,17 +470,13 @@ extension DatabasePool: DatabaseReader {
482470 }
483471
484472 public func asyncUnsafeRead(
485- _ value: sending @escaping ( Result < Database , Error > ) -> Void
473+ _ value: @escaping @ Sendable ( Result < Database , Error > ) -> Void
486474 ) {
487475 guard let readerPool else {
488476 value ( . failure( DatabaseError . connectionIsClosed ( ) ) )
489477 return
490478 }
491479
492- // Avoid compiler warning. There is no data race because `value` is invoked once.
493- typealias SendableClosure = @Sendable ( Result < Database , Error > ) -> Void
494- let value = unsafeBitCast ( value, to: SendableClosure . self)
495-
496480 readerPool. asyncGet { result in
497481 do {
498482 let ( reader, releaseReader) = try result. get ( )
@@ -533,7 +517,7 @@ extension DatabasePool: DatabaseReader {
533517 }
534518
535519 public func spawnConcurrentRead(
536- _ value: sending @escaping ( Result < Database , Error > ) -> Void
520+ _ value: @escaping @ Sendable ( Result < Database , Error > ) -> Void
537521 ) {
538522 asyncConcurrentRead ( value)
539523 }
@@ -576,7 +560,7 @@ extension DatabasePool: DatabaseReader {
576560 ///
577561 /// - parameter value: A function that accesses the database.
578562 public func asyncConcurrentRead(
579- _ value: sending @escaping ( Result < Database , Error > ) -> Void
563+ _ value: @escaping @ Sendable ( Result < Database , Error > ) -> Void
580564 ) {
581565 // Check that we're on the writer queue...
582566 writer. execute { db in
@@ -818,7 +802,7 @@ extension DatabasePool: DatabaseWriter {
818802 }
819803
820804 public func writeWithoutTransaction< T: Sendable > (
821- _ updates: sending @escaping ( Database ) throws -> T
805+ _ updates: @escaping @ Sendable ( Database) throws -> T
822806 ) async throws -> T {
823807 try await writer. execute ( updates)
824808 }
@@ -834,12 +818,8 @@ extension DatabasePool: DatabaseWriter {
834818 }
835819
836820 public func barrierWriteWithoutTransaction< T: Sendable > (
837- _ updates: sending @escaping ( Database ) throws -> T
821+ _ updates: @escaping @ Sendable ( Database) throws -> T
838822 ) async throws -> T {
839- // Avoid compiler warning. There is no data race because `updates` is invoked once.
840- typealias SendableClosure = @Sendable ( Database) throws -> T
841- let updates = unsafeBitCast ( updates, to: SendableClosure . self)
842-
843823 let dbAccess = CancellableDatabaseAccess ( )
844824 return try await dbAccess. withCancellableContinuation { continuation in
845825 asyncBarrierWriteWithoutTransaction { dbResult in
@@ -858,7 +838,7 @@ extension DatabasePool: DatabaseWriter {
858838 }
859839
860840 public func asyncBarrierWriteWithoutTransaction(
861- _ updates: sending @escaping ( Result < Database , Error > ) -> Void
841+ _ updates: @escaping @ Sendable ( Result < Database , Error > ) -> Void
862842 ) {
863843 guard let readerPool else {
864844 updates ( . failure( DatabaseError . connectionIsClosed ( ) ) )
@@ -914,7 +894,7 @@ extension DatabasePool: DatabaseWriter {
914894 }
915895
916896 public func asyncWriteWithoutTransaction(
917- _ updates: sending @escaping ( Database ) -> Void
897+ _ updates: @escaping @ Sendable ( Database ) -> Void
918898 ) {
919899 writer. async ( updates)
920900 }
0 commit comments