Proposal: System.Timeout module for base

Simon Marlow simonmarhaskell at gmail.com
Tue Jan 30 07:20:51 EST 2007


Einar Karttunen wrote:
> On 28.01 17:21, Peter Simons wrote:
>> I am sorry, but I'm uncertain whether I understand your
>> explanation correctly. The problem you describe seems to be that
>> the to-be-timed-out thread blocks because of an FFI call and thus
>> cannot be interrupted when the timeout occurs. Is this what you
>> were saying? If it is, I'm wondering whether that behavior is
>> something that should be credited to the timeout function. In
>> other words, I don't feel that timeout is broken because a
>> blocked FFI call can't receive exceptions. It is, however, a
>> limitation that should be documented.
>>
> 
> Yes, this is the case. Of course one can also write timeout
> combinators that work even if the blocking call is a FFI one.
> 
> Maybe have two variants since the safer one is slightly slower.

How would you interrupt the FFI call when the timeout expired? 
pthread_cancel(), maybe?

Or perhaps you just want to run the IO action in a separate thread, so that 
timeout can return even though the IO action is still blocked.  I'd say this was 
wrong though, because the FFI call will still be running, and that may well be 
visible.

Cheers,
	Simon


More information about the Libraries mailing list