[darcs-users] ctrl-c, windows

Peter Strand peter at zarquon.se
Mon Aug 16 11:08:15 UTC 2004


David Roundy wrote:
> On Mon, Aug 16, 2004 at 12:15:41PM +0200, Peter Strand wrote:
>>David Roundy wrote:
>>>On Mon, Aug 16, 2004 at 10:27:25AM +0200, Peter Strand wrote:
>>
>>I was thinking of "foreign export"-ing the haskell function that raises
>>the exception, and call that directly from the ctrl-c callback. I think 
>>that would work in the threaded rts, but haven't tried it yet..
> 
> Ah, I've never exported a haskell function before... but can you really
> call a haskell function from a separate OS thread? I thought that there
> were locking issues that required that all haskell functions run in the
> same OS thread... on the other hand, I guess maybe that's what the threaded
> rts is for.

Indeed, making sure that there is only one OS-thread executing at the
same time on the haskell side is one of the things the threaded rts
does, only calls to C functions execute in parallell.

> Can you "foreign export" a function that is created at runtime? Because
> won't we need the threadID of the main thread in order to throw the
> exception?

Yes, it is possible. Alternatively, it maybe simpler to just put the
main thread id in a global variable. On the other hand, it might be
possible to avoid any C glue code by calling the win32 function directly
with a haskell callback.
I'll code something up and see how it works out..


/Peter




More information about the darcs-users mailing list