What is the difference between dispatch_time and dispatch_walltime and in what situations is better to use one or the other?

后端 未结 1 1356
孤独总比滥情好
孤独总比滥情好 2021-01-31 05:02

I know that dispatch_time is the time according to device clock and if the device goes to sleep the clock sleeps too. On the other hand the dipatch_walltime

相关标签:
1条回答
  • 2021-01-31 05:08

    dispatch_time stops running when your computer goes to sleep. dispatch_walltime continues running because the real world continues running.

    So suppose you want to do an action 1 hour from now, but after 5 minutes your computer goes to sleep for 50 minutes. Then:

    • dispatch_walltime will execute an hour from now, 5 minutes after the computer wakes up.

    • dispatch_time will execute after the computer is running for an hour, that is 55 minutes after it wakes up, 1 hour and 50 minutes from now.

    0 讨论(0)
提交回复
热议问题