mirror of https://github.com/python/cpython
sort last committed name in alphabetical order
This commit is contained in:
parent
23b0b9252e
commit
f683700121
|
@ -35,6 +35,9 @@ from collections import namedtuple
|
||||||
__all__ = ["scheduler"]
|
__all__ = ["scheduler"]
|
||||||
|
|
||||||
class Event(namedtuple('Event', 'time, priority, action, argument, kwargs')):
|
class Event(namedtuple('Event', 'time, priority, action, argument, kwargs')):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(Event, self).__init__(*args, **kwargs)
|
||||||
|
self._scheduled = False
|
||||||
def __eq__(s, o): return (s.time, s.priority) == (o.time, o.priority)
|
def __eq__(s, o): return (s.time, s.priority) == (o.time, o.priority)
|
||||||
def __ne__(s, o): return (s.time, s.priority) != (o.time, o.priority)
|
def __ne__(s, o): return (s.time, s.priority) != (o.time, o.priority)
|
||||||
def __lt__(s, o): return (s.time, s.priority) < (o.time, o.priority)
|
def __lt__(s, o): return (s.time, s.priority) < (o.time, o.priority)
|
||||||
|
@ -59,6 +62,7 @@ class scheduler:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
event = Event(time, priority, action, argument, kwargs)
|
event = Event(time, priority, action, argument, kwargs)
|
||||||
|
event._scheduled = True
|
||||||
heapq.heappush(self._queue, event)
|
heapq.heappush(self._queue, event)
|
||||||
return event # The ID
|
return event # The ID
|
||||||
|
|
||||||
|
@ -81,6 +85,9 @@ class scheduler:
|
||||||
self._queue.remove(event)
|
self._queue.remove(event)
|
||||||
heapq.heapify(self._queue)
|
heapq.heapify(self._queue)
|
||||||
|
|
||||||
|
def is_scheduled(self, event):
|
||||||
|
return event._scheduled
|
||||||
|
|
||||||
def empty(self):
|
def empty(self):
|
||||||
"""Check whether the queue is empty."""
|
"""Check whether the queue is empty."""
|
||||||
return not self._queue
|
return not self._queue
|
||||||
|
@ -122,6 +129,7 @@ class scheduler:
|
||||||
# Verify that the event was not removed or altered
|
# Verify that the event was not removed or altered
|
||||||
# by another thread after we last looked at q[0].
|
# by another thread after we last looked at q[0].
|
||||||
if event is checked_event:
|
if event is checked_event:
|
||||||
|
event._scheduled = False
|
||||||
action(*argument, **kwargs)
|
action(*argument, **kwargs)
|
||||||
delayfunc(0) # Let other threads run
|
delayfunc(0) # Let other threads run
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -11,7 +11,6 @@ Without you, I would've stopped working on Python long ago!
|
||||||
PS: In the standard Python distribution, this file is encoded in UTF-8
|
PS: In the standard Python distribution, this file is encoded in UTF-8
|
||||||
and the list is in rough alphabetical order by last names.
|
and the list is in rough alphabetical order by last names.
|
||||||
|
|
||||||
Chris Clark
|
|
||||||
Rajiv Abraham
|
Rajiv Abraham
|
||||||
David Abrahams
|
David Abrahams
|
||||||
Ron Adam
|
Ron Adam
|
||||||
|
@ -179,6 +178,7 @@ Tom Christiansen
|
||||||
Vadim Chugunov
|
Vadim Chugunov
|
||||||
David Cinege
|
David Cinege
|
||||||
Craig Citro
|
Craig Citro
|
||||||
|
Chris Clark
|
||||||
Mike Clarkson
|
Mike Clarkson
|
||||||
Andrew Clegg
|
Andrew Clegg
|
||||||
Brad Clements
|
Brad Clements
|
||||||
|
|
Loading…
Reference in New Issue