-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Migrate Store to Actor #2
Comments
I just found a ton of race conditions in my app because I implicitly assumed the items access in the store was thread safe. Moving to an actor would be ideal to remove all these issues in one go. It's a fairly straight forward process, since all the operations are already marked as async. However, we will lose main thread access to the $items publisher in its current configuration. @mergesort it's been a few years since you opened this issue, and perhaps you're more familiar with the Actor api. Curious if you had any insight in what you'd like to do now? |
Hey @levi, sorry for the delayed reply — I'm just digging myself out of a lot of work (though heading right into my wedding so I may be busy for the next week or so as well). 😅 If it isn't too much trouble I would absolutely love to have some more examples of the race conditions you ran into, my assumption was that Boutique generally is thread safe. It would also be helpful to know if you used the SQLiteStorageEngine or the DiskStorageEngine. More generally I plan to take a deep dive into Boutique this summer, starting with a concurrency upgrade to hopefully quell issues like this. I have from time to time ran Boutique through Swift's strict concurrency checking and only found minor warnings, and so I generally decided to wait on changes until Swift 6. There's a chance that the diagnostics didn't trigger for whatever reason and I suspect that once Swift 6 is official a lot more issues will come up given how difficult a subject concurrency is, so I thought it best to wait given how fast the concurrency tooling has been changing over the last few months. I also consider a migration to Swift 6 to be a good time to make breaking changes, for example if $items has to change. I am hoping to migrate Boutique to Observable so that may not be a huge deal, though there are a lot of caveats behind that statement given how many different types there are in Boutique that will likely have to be converted to macros. I would also like to say that I am super open to suggestions, I consider this a collaborative process, so if you have any ideas for how to make this work I am all ears! Sorry again for the race conditions you ran into, I hope it wasn't too painful of an issue. |
@mergesort hi sorry just getting back into this now. The issue I saw is the |
@mergesort I migrated to something like this in my own projects:
The downside of this current implementation is that you can never access the Store actor directly, you must always go through the @observable class to keep it in sync. Def a simple GPT written solution, but solves most of my needs at the moment. |
Currently this requires only a few code changes but adds warnings that I honestly am not familiar enough with to figure out the right solution, so I would be grateful for help from anyone who understands the Actor model well.
The text was updated successfully, but these errors were encountered: