Concurrent Read / Write access #3204
Unanswered
artemkrachulov
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi @artemkrachulov, I believe these docs should answer your question. CPU intensive calculations can be moved to an effect and then the results sent back to the reducer in order to mutate the state's feature. The only thing to be cautious of is that seriously CPU intensive work isn't recommended to be performed in the cooperative thread pool, which is where return .run { send in
await withUnsafeContinuation { continuation in
backgroundQueue.async {
// Do work
DispatchQueue.main.async {
// Send results back
send(/*results*/)
}
continuation.resume()
}
}
} However, if your CPU work doesn't take too much time you may not need to go this far. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Good day, to all! I'm looking for some advice from you.
We have a feature containing the list of items. Initially, all operations performed with 0(n) complexity, read/write access performed within the main thread. Meanwhile amount of operations increased and I started thinking about optimization and moving heavy operations to background threads. With old legacy CGD we have a bunch of variants like barriers, locks, etc... to achieve this. But with TCA + structured concurrency I have no idea how to do that. Вelow is an example of my feature:
Asking for help 🙏
Beta Was this translation helpful? Give feedback.
All reactions