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.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/realtime/rt/util.py b/realtime/rt/util.py
index 6e07f116..05dcae96 100644
--- a/realtime/rt/util.py
+++ b/realtime/rt/util.py
@@ -1,4 +1,5 @@
import os
+import Queue
import subprocess
import sys
import threading
@@ -13,6 +14,24 @@ SA_INI_FILES = set((
'precompute_file',
))
+class FIFOLock:
+
+ def __init__(self):
+ self.q = Queue.Queue()
+ self.i = 0
+
+ def acquire(self):
+ self.i += 1
+ if self.i > 1:
+ event = threading.Event()
+ self.q.put(event)
+ event.wait()
+
+ def release(self):
+ self.i -= 1
+ if self.i > 0:
+ self.q.get().set()
+
def cdec_ini_for_config(config):
# This is a list of (k, v), not a ConfigObj or dict
for i in range(len(config)):