scheduler.py

changeset 59
8d0a815022cc
parent 55
407af23d16bb
child 69
8705e296c7a0
equal deleted inserted replaced
58:170d69da51bb 59:8d0a815022cc
75 self._list=ev 75 self._list=ev
76 elif ev<self._list: 76 elif ev<self._list:
77 ev.insert_immediately_after(self._list) 77 ev.insert_immediately_after(self._list)
78 self._list=ev 78 self._list=ev
79 else: 79 else:
80 self._list.insert_immediately_after(ev) 80 self._list.insert_after(ev)
81 81
82 self._cond.notify() 82 self._cond.notify()
83 83
84 def _unlink(self, ev): 84 def _unlink(self, ev):
85 if ev==self._list: 85 if ev==self._list:
111 self._cond.wait(timeout) 111 self._cond.wait(timeout)
112 now = time.monotonic() 112 now = time.monotonic()
113 113
114 while self._list and self._list.when <= now: 114 while self._list and self._list.when <= now:
115 ev=self._list 115 ev=self._list
116 logger.debug("Scheduling event %s" % (ev.name or "(unknown)")) 116 logger.debug("Scheduler activating %s" % (ev.name or "(unknown)"))
117 # We are only allowed to remove ev from list when ev.cond allows 117 # We are only allowed to remove ev from list when ev.cond allows
118 with ev.cond: 118 with ev.cond:
119 self._list=ev.next 119 self._list=ev.next
120 ev.unlink() 120 ev.unlink()
121 ev.cond.notifyAll() 121 ev.cond.notifyAll()

mercurial