SIGN IN SIGN UP

Refactor:

* Improve algorithm -- no more O(n) steps except sched.cancel().
* Improve thread safety of sched.run() and sched.empty()
  (other threads could alter the queue between the time the queue was
   first checked and when the lead event was deleted).
* Localize variable access in sched.run() to minimize overhead.
R
Raymond Hettinger committed
bf72b7163018924e42a272b4e70601f394e840e6
Parent: 6f5b741