mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
Fetching on a background thread #224
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Guferos on GitHub (Jul 31, 2018).
It might sound trivial but I cannot find a good way to do it. I need to pass a Core Data object to a background thread where I will be only performing read operations with that object.
The only way I found to do it is:
However it feels wrong as my code will be performed on the CoreStore queue instead of mine.
Is there a way to create a transaction inside the actionsQueue and fetch the myCDObject without wrapping it into perform asynchronous block?
@JohnEstropia commented on GitHub (Jul 31, 2018):
You can use
CoreStore.perform(synchronous:)if your queueing mechanism isn't that complex, but you may encounter deadlocks otherwise. If you are sure to be just reading from the object, you can useCoreStore.beginUnsafe()to create a transaction that acts as a background, read-only, temporary transaction. From that you can just fetch your object within your queue.