Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • Yes, it does. If you don't use recursion in your sleep and wakeup functions then you won't have this problem. Commented Sep 6, 2017 at 23:18
  • Ok. How can the recursion be replaced in such a way I don't miss events while transitioning from running to sleeping? Commented Sep 7, 2017 at 6:18
  • 2
    Well I'd write the main loop as while(true) {drain();} and then sleep doesn't need to call wakeup, it can just return without sleeping. To avoid the potential deadlock I'd use a condition variable for state. Commented Sep 8, 2017 at 6:59
  • @immibis Good, might want to make it a real answer. Commented Sep 11, 2017 at 21:35