summaryrefslogtreecommitdiff
path: root/realtime/rt/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'realtime/rt/util.py')
-rw-r--r--realtime/rt/util.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/realtime/rt/util.py b/realtime/rt/util.py
index 05dcae96..52767dac 100644
--- a/realtime/rt/util.py
+++ b/realtime/rt/util.py
@@ -15,22 +15,30 @@ SA_INI_FILES = set((
))
class FIFOLock:
+ '''Lock that preserves FIFO order of blocking threads'''
def __init__(self):
self.q = Queue.Queue()
self.i = 0
+ self.lock = threading.Lock()
def acquire(self):
+ self.lock.acquire()
self.i += 1
if self.i > 1:
event = threading.Event()
self.q.put(event)
+ self.lock.release()
event.wait()
+ return
+ self.lock.release()
def release(self):
+ self.lock.acquire()
self.i -= 1
if self.i > 0:
self.q.get().set()
+ self.lock.release()
def cdec_ini_for_config(config):
# This is a list of (k, v), not a ConfigObj or dict