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

program quits when using async/await #15

Open
amnykon opened this issue Oct 16, 2023 · 1 comment
Open

program quits when using async/await #15

amnykon opened this issue Oct 16, 2023 · 1 comment

Comments

@amnykon
Copy link

amnykon commented Oct 16, 2023

When using async/await, The program quits. I have tried only using Raylib commands on the Main Actor and main thread. Still crashes if there is an await.

I got it working with the following work around; however, this ties up the main thread with a semaphore.

    @MainActor static func main() {
        Raylib.initWindow(800, 450, "test")
        Raylib.setTargetFPS(60)
        
        while Raylib.windowShouldClose == false {
            let semaphore = DispatchSemaphore(value: 0)
            DispatchQueue.global().async {
                Task {
                    await update()
                    semaphore.signal()
                }
            }
            semaphore.wait()
            draw()
        }
        
        Raylib.closeWindow()
    }
@7ombie
Copy link

7ombie commented Sep 11, 2024

This sounds like it could be a pretty serious issue. Swift is big on concurrency. It'd be nice to know more at least.

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