diff options
author | Raymond Hettinger <python@rcn.com> | 2004-01-29 06:37:52 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-01-29 06:37:52 (GMT) |
commit | 756b3f3c15bd314ffa25299ca25465ae21e62a30 (patch) | |
tree | f504d3ab53c151b7e88ebfebd069a034f80f5025 /Lib/mutex.py | |
parent | 141d4e564314abde44189eb5e3a9f509dab045ff (diff) | |
download | cpython-756b3f3c15bd314ffa25299ca25465ae21e62a30.zip cpython-756b3f3c15bd314ffa25299ca25465ae21e62a30.tar.gz cpython-756b3f3c15bd314ffa25299ca25465ae21e62a30.tar.bz2 |
* Move collections.deque() in from the sandbox
* Add unittests, newsitem, and whatsnew
* Apply to Queue.py mutex.py threading.py pydoc.py and shlex.py
* Docs are forthcoming
Diffstat (limited to 'Lib/mutex.py')
-rw-r--r-- | Lib/mutex.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/mutex.py b/Lib/mutex.py index e15710a..5d35bdf 100644 --- a/Lib/mutex.py +++ b/Lib/mutex.py @@ -12,11 +12,13 @@ Of course, no multi-threading is implied -- hence the funny interface for lock, where a function is called once the lock is aquired. """ +from collections import deque + class mutex: def __init__(self): """Create a new mutex -- initially unlocked.""" self.locked = 0 - self.queue = [] + self.queue = deque() def test(self): """Test the locked bit of the mutex.""" @@ -44,7 +46,7 @@ class mutex: """Unlock a mutex. If the queue is not empty, call the next function with its argument.""" if self.queue: - function, argument = self.queue.pop(0) + function, argument = self.queue.popleft() function(argument) else: self.locked = 0 |