Replies: 1 comment
-
My current attempt is to fold the public class Processor {
static let processorQueue = DispatchQueue(label: "keepers.Processor", attributes: .concurrent)
init() { ... }
public func run() {
processorQueue.async {
...
}
}
}
@Dependency(\.processor) var processor
public func reduce(state, action) -> Effect<Action, Never> {
switch action {
case .start:
return .run { send in
processor.run()
}
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi folks, we have a long-running background process that takes quite a while to execute (5min ~ 30min depends on the device). We built several prototypes to evaluate the correct way to structure this. It turns out that running it on a concurrent
DispatchQueue
viaasync
was the most performant and memory-safe way. We had a version using Swift's newTaskGroup
, but it didn't perform as well. Our current code looks like thisI'm wondering what's the right way to create an
Effect
to kick the task off in the TCA world. Reading through theEffect.run
implementation, it looks like it uses TaskGroup under the hood.Thanks,
Alex
Beta Was this translation helpful? Give feedback.
All reactions