Browse thread
[Caml-list] signals & threading
- Jonathan Roewen
[
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: | 2006-02-24 (12:09) |
From: | Jonathan Roewen <jonathan.roewen@g...> |
Subject: | [Caml-list] signals & threading |
Here's some example code once posted on the list to have a timeout. let set_timer tsecs = ignore (Unix.setitimer Unix.ITIMER_REAL { Unix.it_interval = 0.0; Unix.it_value = tsecs }) exception Timeout let handle_sigalrm signo = print_string "Continue for how long? "; flush stdout; let f = read_float() in if f <= 0.0 then raise Timeout else set_timer f let continueq f arg tsecs defaultval = let oldsig = Sys.signal Sys.sigalrm (Sys.Signal_handle handle_sigalrm) in try set_timer tsecs; let res = f arg in set_timer 0.0; Sys.set_signal Sys.sigalrm oldsig; res with Timeout -> Sys.set_signal Sys.sigalrm oldsig; defaultval Now, my question is: what happens with multiple threads? The exception is raised in whatever thread is currently running? Is there also no control over such behaviour? Jonathan