SQLite.swift icon indicating copy to clipboard operation
SQLite.swift copied to clipboard

Add an optional target queue to for database operations

Open sharplet opened this issue 7 years ago • 1 comments

The optional target queue is useful for synchronising other work with respect to database operations. Provided the target queue is also a serial queue, work submitted to the private connection queue and work submitted directly to the target queue will still be executed in serial.

The queue context is now set on the target queue if present. The connection queue inherits values set on the target queue, so the call to DispatchQueue.getSpecific, using queueKey, returns queueContext as expected. For this logic to still be thread-safe, the target queue must be a serial queue. queueKey is now an instance variable so that every connection gets a unique key, ensuring that connections can't write over one another's context variables.

The attributes: parameter is also removed from the call to initialise the database queue, as [] (i.e., serial) is already the default.

sharplet avatar Apr 21 '18 18:04 sharplet

Perhaps related to #937

nathanfallet avatar Aug 26 '21 13:08 nathanfallet