diff options
author | Damien Doligez <damien.doligez-inria.fr> | 2004-06-14 13:27:42 +0000 |
---|---|---|
committer | Damien Doligez <damien.doligez-inria.fr> | 2004-06-14 13:27:42 +0000 |
commit | cd64d89caf1fa04fcdddf45ec0e8c16df5b69242 (patch) | |
tree | 82f45080344ffd4811fbe640da58fb605a575562 /stdlib/gc.mli | |
parent | 999ba4d80562f404506698cf0719a278debca5a4 (diff) | |
download | ocaml-cd64d89caf1fa04fcdddf45ec0e8c16df5b69242.tar.gz |
finalisation dans l'ordre
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6403 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'stdlib/gc.mli')
-rw-r--r-- | stdlib/gc.mli | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/stdlib/gc.mli b/stdlib/gc.mli index 491faab393..bafa8ed9f7 100644 --- a/stdlib/gc.mli +++ b/stdlib/gc.mli @@ -188,14 +188,15 @@ val finalise : ('a -> unit) -> 'a -> unit be registered for the same value, or even several instances of the same function. Each instance will be called once (or never, if the program terminates before [v] becomes unreachable). - - - A number of pitfalls are associated with finalised values: - finalisation functions are called asynchronously, sometimes - even during the execution of other finalisation functions. - In a multithreaded program, finalisation functions are called - from any thread, thus they must not acquire any mutex. + The GC will call the finalisation functions in the order of + deallocation. When several values become unreachable at the + same time (i.e. during the same GC cycle), the finalisation + functions will be called in the reverse order of the corresponding + calls to [finalise]. If [finalise] is called in the same order + as the values are allocated, that means each value is finalised + before the values it depends upon. Of course, this becomes + false if additional dependencies are introduced by assignments. Anything reachable from the closure of finalisation functions is considered reachable, so the following code will not work @@ -232,10 +233,14 @@ val finalise : ('a -> unit) -> 'a -> unit The results of calling {!String.make}, {!String.create}, {!Array.make}, and {!Pervasives.ref} are guaranteed to be - heap-allocated and non-constant - except when the length argument is [0]. + heap-allocated and non-constant except when the length argument is [0]. *) +val finalise_release : unit -> unit;; +(** A finalisation function may call [finalise_release] to tell the + GC that it can launch the next finalisation function without waiting + for the current one to return. *) + type alarm (** An alarm is a piece of data that calls a user function at the end of each major GC cycle. The following functions are provided to create |