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

hack around 0xdead10cc #1210

Merged
merged 2 commits into from
May 14, 2021
Merged

hack around 0xdead10cc #1210

merged 2 commits into from
May 14, 2021

Conversation

r10s
Copy link
Member

@r10s r10s commented May 13, 2021

targets #1202

@r10s r10s changed the title wait until dispatched jobs are done hack around 0xdead10cc May 13, 2021
@r10s r10s force-pushed the hack-around-0xdead10cc branch 2 times, most recently from 5d32e0a to 6a08c68 Compare May 13, 2021 12:39
@r10s
Copy link
Member Author

r10s commented May 13, 2021

hm, that does not work as waitForExistingJobsDispatched is itself called from main, so, mainDoneSoFar never gets true. needs some more love ...

@cyBerta
Copy link
Contributor

cyBerta commented May 13, 2021

Why don't you move the completion handler itself to the background queue?

something like:

DispatchQueue.global(qos: .background).async {
            completionHandler(.newData)
}

@r10s r10s force-pushed the hack-around-0xdead10cc branch 2 times, most recently from ceeabde to 73db6a1 Compare May 13, 2021 16:18
@r10s r10s marked this pull request as ready for review May 13, 2021 16:22
@r10s r10s force-pushed the hack-around-0xdead10cc branch 2 times, most recently from 30605a0 to 422646d Compare May 14, 2021 10:24
@r10s r10s force-pushed the hack-around-0xdead10cc branch from 1850706 to 1ed1353 Compare May 14, 2021 13:43
@r10s r10s force-pushed the hack-around-0xdead10cc branch from 1ed1353 to dddaf1a Compare May 14, 2021 13:48
@r10s
Copy link
Member Author

r10s commented May 14, 2021

i just played around a bit with DispatchQueue.global.async in the ios emulator as well as on a real iphone7:

  • up to 64 jobs are started concurrently
  • jobs are mostly started in the correct order, at least when there is little time between scheduling them
  • when the last queued job is done, up to 63 other jobs may still be running.

so, an additional DispatchQueue.global.async around DispatchQueue.main.asyncAfter only makes sense if we assume there are lots of jobs queued. but then, it may make sense.

code used for testing
        for i in 0 ..< 100 {
            usleep(UInt32(i) * 1000)
            logger.info("😇 queuing job \(i)")
            DispatchQueue.global().async {
                logger.info("🟢 job \(i) started")
                usleep(UInt32(i) * 1000*1000)
                logger.info("🔴 job \(i) done")
            }
        }

@r10s r10s merged commit d0e46ad into master May 14, 2021
@r10s r10s deleted the hack-around-0xdead10cc branch May 14, 2021 15:21
@r10s r10s added the notify label May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants