diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2000-07-28 12:23:53 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2000-07-28 12:23:53 +0000 |
commit | 169d14212b9a9c9d2aad1ca1bcddb172af4c09c6 (patch) | |
tree | 57069eb70aecc6ae0bbe5a3ed6f42b848c8baf33 | |
parent | eb924a201fa0224213cdbbb276d0e45a9c467fdf (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.ml | 15 | ||||
-rw-r--r-- | otherlibs/threads/event.ml | 15 |
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 *) |