Browse thread
Are unreachable threads garbage collected?
- Ker Lutyn
[
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: | Ker Lutyn <ker527mail@y...> |
| Subject: | Are unreachable threads garbage collected? |
>From Reppy's paper, an implementation of buffered channels translated to OCaml.
Note the internal thread to manage the state. If the buffered channel becomes
unreachable, will this thread be garbage collected?
module Buffered_channel = struct
open Event
type 'a t = 'a channel * 'a channel
let make () =
let i = new_channel () in
let o = new_channel () in
let rec loop = function
| [], [] -> loop ([sync (receive i)], [])
| (a :: aa) as aaa, bbb -> select [
wrap (receive i) (fun x -> loop (aaa, x :: bbb));
wrap (send o a) (fun () -> loop (aa, bbb))
]
| [], bbb -> loop (List.rev bbb, [])
in ignore (Thread.create loop ([], [])); (i, o)
let send (i, _) x = Event.send i x
let receive (_, o) = Event.receive o
end
__________________________________
Start your day with Yahoo! - Make it your home page!
http://www.yahoo.com/r/hs