summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2000-07-28 12:23:53 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2000-07-28 12:23:53 +0000
commit169d14212b9a9c9d2aad1ca1bcddb172af4c09c6 (patch)
tree57069eb70aecc6ae0bbe5a3ed6f42b848c8baf33
parenteb924a201fa0224213cdbbb276d0e45a9c467fdf (diff)
sync et tail-recursion
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3261 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--otherlibs/systhreads/event.ml15
-rw-r--r--otherlibs/threads/event.ml15
2 files changed, 20 insertions, 10 deletions
diff --git a/otherlibs/systhreads/event.ml b/otherlibs/systhreads/event.ml
index 972cce74c..c81886933 100644
--- a/otherlibs/systhreads/event.ml
+++ b/otherlibs/systhreads/event.ml
@@ -89,11 +89,16 @@ let basic_sync abort_env genev =
end;
Mutex.unlock masterlock;
(* Extract the result *)
- let num = !performed in
- let result = bev.(!performed).result() in
- (* Handle the aborts and return the result *)
- do_aborts abort_env genev num;
- result
+ if abort_env = [] then
+ (* Preserve tail recursion *)
+ bev.(!performed).result()
+ else begin
+ let num = !performed in
+ let result = bev.(num).result() in
+ (* Handle the aborts and return the result *)
+ do_aborts abort_env genev num;
+ result
+ end
(* Apply a random permutation on an array *)
diff --git a/otherlibs/threads/event.ml b/otherlibs/threads/event.ml
index 972cce74c..c81886933 100644
--- a/otherlibs/threads/event.ml
+++ b/otherlibs/threads/event.ml
@@ -89,11 +89,16 @@ let basic_sync abort_env genev =
end;
Mutex.unlock masterlock;
(* Extract the result *)
- let num = !performed in
- let result = bev.(!performed).result() in
- (* Handle the aborts and return the result *)
- do_aborts abort_env genev num;
- result
+ if abort_env = [] then
+ (* Preserve tail recursion *)
+ bev.(!performed).result()
+ else begin
+ let num = !performed in
+ let result = bev.(num).result() in
+ (* Handle the aborts and return the result *)
+ do_aborts abort_env genev num;
+ result
+ end
(* Apply a random permutation on an array *)