aboutsummaryrefslogtreecommitdiffhomepage
path: root/stm
diff options
context:
space:
mode:
authorGravatar Enrico Tassi <Enrico.Tassi@inria.fr>2014-06-26 15:38:49 +0200
committerGravatar Enrico Tassi <Enrico.Tassi@inria.fr>2014-07-10 15:22:58 +0200
commit19d2075236c4c3fd932f7cf003b9f7283dafaeca (patch)
tree2a0d7c5a12ddbb88084fbb896ed221bd0aba2e33 /stm
parentedee36d00147dfaa99acf52a7b4d7ebf329b013f (diff)
more APIs in TQueue and CThread
These are now sufficient to implement PIDE
Diffstat (limited to 'stm')
-rw-r--r--stm/tQueue.ml7
-rw-r--r--stm/tQueue.mli2
2 files changed, 9 insertions, 0 deletions
diff --git a/stm/tQueue.ml b/stm/tQueue.ml
index 783c545fd..bf55eaf77 100644
--- a/stm/tQueue.ml
+++ b/stm/tQueue.ml
@@ -42,6 +42,13 @@ let push { queue = q; lock = m; cond = c } x =
Condition.signal c;
Mutex.unlock m
+let clear { queue = q; lock = m; cond = c } =
+ Mutex.lock m;
+ Queue.clear q;
+ Mutex.unlock m
+
+let is_empty { queue = q } = Queue.is_empty q
+
let wait_until_n_are_waiting_and_queue_empty j tq =
Mutex.lock tq.lock;
while not (Queue.is_empty tq.queue) || tq.nwaiting < j do
diff --git a/stm/tQueue.mli b/stm/tQueue.mli
index a3ea5532f..f3703285a 100644
--- a/stm/tQueue.mli
+++ b/stm/tQueue.mli
@@ -15,3 +15,5 @@ val push : 'a t -> 'a -> unit
val reorder : 'a t -> ('a -> 'a -> int) -> unit
val wait_until_n_are_waiting_and_queue_empty : int -> 'a t -> unit
val dump : 'a t -> 'a list
+val clear : 'a t -> unit
+val is_empty : 'a t -> bool