Add an optional target queue to for database operations #801
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
, usingqueueKey
, returnsqueueContext
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.