diff options
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 |