Re: [swift-users] DispatchQueue.async within infinite loop

2017-10-04 Thread Jeremy W. Sherman via swift-users
Something has to drain blocks sent to the main queue. You can run a Foundation run loop. That should drain the main queue. I believe it also ensures blocks sent to the main queue always run on the main thread. Dispatch includes its own lower-level function to pump the main queue: dispatch_main.

Re: [swift-users] DispatchQueue.async within infinite loop

2017-10-04 Thread Rahul Ranjan via swift-users
Hi Geordie, I am new here and so pardon me if I misunderstood anything. When you run a program in Swift, it already runs on main thread by default and then you can all Dispatch async. So for example, while true { // This while loop will run for infinite on main thread Dispatch.main.async {} //

[swift-users] DispatchQueue.async within infinite loop

2017-10-04 Thread Geordie J via swift-users
Hi! I have a somewhat unusual use-case that I’m trying to figure out. I have a command-line swift app whose main thread ends up in an infinite loop for graphics rendering purposes (running SDL). What I’m hoping to do is to be able to run async code like this from within that infinite loop: Di