Skip to content

[v2] [1/X] ApolloStore async Read/Write lock #646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: v2
Choose a base branch
from
Open

Conversation

AnthonyMDev
Copy link
Contributor

Creates a ReaderWriter using SwiftAtomics that allows for multiple parallel reads while locking for writes.

This will replace the current barrier queue for ApolloStore. Usage of this will be implemented in stacked PR.

@AnthonyMDev AnthonyMDev marked this pull request as ready for review May 15, 2025 22:19
@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented May 15, 2025

⚠️ Docs preview not attached to branch

The preview was not built because the PR's base branch v2 is not in the list of sources.

An Apollo team member can comment one of the following commands to dictate which branch to attach the preview to:

  • !docs set-base-branch main

Build ID: b87e5157d246455d6d20d5a1

@@ -49,7 +50,7 @@ public class ApolloStore: @unchecked Sendable {
/// - callbackQueue: The queue to call the completion block on. Defaults to `DispatchQueue.main`.
/// - completion: [optional] A completion block to be called after records are merged into the cache.
public func clearCache(callbackQueue: DispatchQueue = .main, completion: ((Result<Void, any Swift.Error>) -> Void)? = nil) {
queue.async(flags: .barrier) {
readerWriterLock.write {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been part of the ApolloStore PR that is stacked on this branch, but accidentally got included here.

This shouldn't matter too much, as that branch will be merged into this before merging this up the stack.

@AnthonyMDev AnthonyMDev changed the title [v2] ApolloStore async Read/Write lock [v2] [1/X] ApolloStore async Read/Write lock May 15, 2025
@calvincestari
Copy link
Member

Going to slowly make our way through these during the week - there is a lot to review. 😓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants