Skip to content
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

I think it's time to enable Enabling Concurrency warnings in Xcode #133

Open
haifengkao opened this issue Nov 13, 2023 · 2 comments
Open

Comments

@haifengkao
Copy link
Collaborator

haifengkao commented Nov 13, 2023

截圖 2023-11-13 下午8 34 36

The warning should not appear, because SwiftRex always calls IO in main thread.

The problem is
Swift does not know SwiftRex will always call IO in main thread.
And IO class itself does not enforce this rule.
I think SwiftRex need a MainIO class, which is guaranteed to run in main thread, but it is going to be a breaking change.

@luizmb
Copy link
Member

luizmb commented Nov 14, 2023

The problem is that we should not assume IO runs on the main thread. We could run IO in a background process, or IO itself could start a background task and even dispatch actions from whatever thread to the store. The reducer MUST run on main queue, because it's dealing with the state (shared resource), that's for sure. And the only reason the actions go to the main queue is to ensure FIFO rule, but they could be actually in any serial queue.

So I'm wondering if we should start enforcing IO to be in the main queue explicitly or not. The Store could be a main actor, and the IO could run on an attached Task. But I'm not sure if this complexity will benefit SwiftRex, but it may be necessary once I finish the Modern Concurrency version of SwiftRex, where either Combine or AsyncStream/Task can be used for creating IO middlewares.
Let me know your opinion on that.

@haifengkao
Copy link
Collaborator Author

You are right. I think it's more ideal to run middleware-returned IO on an attached Task.

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

No branches or pull requests

2 participants