summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 *)