summaryrefslogtreecommitdiffstats
path: root/Lib/dos-8x3/queue.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-08-12 02:38:11 (GMT)
committerGuido van Rossum <guido@python.org>1998-08-12 02:38:11 (GMT)
commite03c05059534b4783c5631517cb16f79531358e8 (patch)
tree82285bf56d90ac5c062f328516a959dd416b8e45 /Lib/dos-8x3/queue.py
parent887d072cc04be23e6758257b326499bd1572b929 (diff)
downloadcpython-e03c05059534b4783c5631517cb16f79531358e8.zip
cpython-e03c05059534b4783c5631517cb16f79531358e8.tar.gz
cpython-e03c05059534b4783c5631517cb16f79531358e8.tar.bz2
The usual.
Diffstat (limited to 'Lib/dos-8x3/queue.py')
-rwxr-xr-xLib/dos-8x3/queue.py50
1 files changed, 25 insertions, 25 deletions
diff --git a/Lib/dos-8x3/queue.py b/Lib/dos-8x3/queue.py
index 843b9dc..5e698ea 100755
--- a/Lib/dos-8x3/queue.py
+++ b/Lib/dos-8x3/queue.py
@@ -19,28 +19,28 @@ class Queue:
self._init(maxsize)
self.mutex = thread.allocate_lock()
self.esema = thread.allocate_lock()
- self.esema.acquire_lock()
+ self.esema.acquire()
self.fsema = thread.allocate_lock()
def qsize(self):
"""Returns the approximate size of the queue (not reliable!)."""
- self.mutex.acquire_lock()
+ self.mutex.acquire()
n = self._qsize()
- self.mutex.release_lock()
+ self.mutex.release()
return n
def empty(self):
"""Returns 1 if the queue is empty, 0 otherwise (not reliable!)."""
- self.mutex.acquire_lock()
+ self.mutex.acquire()
n = self._empty()
- self.mutex.release_lock()
+ self.mutex.release()
return n
def full(self):
"""Returns 1 if the queue is full, 0 otherwise (not reliable!)."""
- self.mutex.acquire_lock()
+ self.mutex.acquire()
n = self._full()
- self.mutex.release_lock()
+ self.mutex.release()
return n
def put(self, item):
@@ -48,30 +48,30 @@ class Queue:
If the queue is full, block until a free slot is avaiable.
"""
- self.fsema.acquire_lock()
- self.mutex.acquire_lock()
+ self.fsema.acquire()
+ self.mutex.acquire()
was_empty = self._empty()
self._put(item)
if was_empty:
- self.esema.release_lock()
+ self.esema.release()
if not self._full():
- self.fsema.release_lock()
- self.mutex.release_lock()
+ self.fsema.release()
+ self.mutex.release()
def get(self):
"""Gets and returns an item from the queue.
This method blocks if necessary until an item is available.
"""
- self.esema.acquire_lock()
- self.mutex.acquire_lock()
+ self.esema.acquire()
+ self.mutex.acquire()
was_full = self._full()
item = self._get()
if was_full:
- self.fsema.release_lock()
+ self.fsema.release()
if not self._empty():
- self.esema.release_lock()
- self.mutex.release_lock()
+ self.esema.release()
+ self.mutex.release()
return item
# Get an item from the queue if one is immediately available,
@@ -83,27 +83,27 @@ class Queue:
this raises the Empty exception if the queue is empty or
temporarily unavailable.
"""
- locked = self.esema.acquire_lock(0)
- self.mutex.acquire_lock()
+ locked = self.esema.acquire(0)
+ self.mutex.acquire()
if self._empty():
# The queue is empty -- we can't have esema
- self.mutex.release_lock()
+ self.mutex.release()
raise Empty
if not locked:
- locked = self.esema.acquire_lock(0)
+ locked = self.esema.acquire(0)
if not locked:
# Somebody else has esema
# but we have mutex --
# go out of their way
- self.mutex.release_lock()
+ self.mutex.release()
raise Empty
was_full = self._full()
item = self._get()
if was_full:
- self.fsema.release_lock()
+ self.fsema.release()
if not self._empty():
- self.esema.release_lock()
- self.mutex.release_lock()
+ self.esema.release()
+ self.mutex.release()
return item
# XXX Need to define put_nowait() as well.