Queues
-
A queue providing serialized execution of work items on a database.
A database queue manages the execution of database operations to ensure they occur one at a time in FIFO order. This provides thread-safe database access.
Database operations may be submitted for synchronous or asynchronous execution.
The interface is similar to
DispatchQueue
and a dispatch queue is used internally for work item management.let dbQueue = try DatabaseQueue() try dbQueue.sync { db in // Do something with `db` }
A database queue also supports transactions and savepoints:
See moredbQueue.transaction { db in // All database operations here are contained within a transaction return .commit }
Declaration
Swift
public final class DatabaseQueue
-
A queue providing serialized execution of read operations on a database.
Normally read queues are used for concurrent read access to databases using WAL mode.
A database read queue manages the execution of read-only database operations to ensure they occur one at a time in FIFO order. This provides thread-safe database access.
Database read operations may be submitted for synchronous or asynchronous execution.
It is possible to maintain a consistent snapshot of a database using read transactions. Changes committed to a database are not visible within a read transaction until the transaction is updated or restarted.
The interface is similar to
See moreDispatchQueue
and a dispatch queue is used internally for work item management.Declaration
Swift
public final class DatabaseReadQueue