[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Damien Doligez <damien.doligez@i...> |
| Subject: | Re: [Caml-list] Finalizers and threads |
On Friday, December 12, 2003, at 04:58 PM, Markus Mottl wrote: > I'd like to know whether it is safe to use "enter_blocking_section" > in finalization functions (C) to allow execution of other threads when > some operation there (e.g. shutting down some TCP/IP-connection) may > block for some time. It is not safe. The finalization function is called right in the middle of the GC, and executing some ML code at that point, even in another thread, is going to result in a disaster. I guess you should defer the blocking operations by pushing them into a queue, and perform them after the GC is done (or in another thread). Note that the contents of the finalized block itself is destroyed as soon as your finalization function returns, so you should make a copy of the data you need. -- Damien ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners