What happens to my app when my Mac goes to sleep?

前端 未结 5 1770
被撕碎了的回忆
被撕碎了的回忆 2021-02-01 23:05

When Mac OS X goes to sleep, due to closing a laptop or selecting \"Sleep\" from the Apple menu, how does it suspend an executing process?

I suppose non-windowed process

5条回答
  •  孤独总比滥情好
    2021-02-01 23:48

    I believe it will just suspend all apps wherever they happen to be.

    Remember, this happens all the time anyway. Applications are constantly suspended and resumed due to context switching. So, really, the clock could jump between any 2 instructions in your app, though usually not in a noticable/significant way.

    If the OS waited for the app to return to some main loop you could run into situations where applications cause the sleep to hang. If they're doing a lot of work and not returning to the run loop dispatcher they would prevent the machine from going to sleep. That wouldn't be very good. :)

提交回复
热议问题