[Haskell] Re: ANN: HDBC (Haskell Database Connectivity)

Simon Marlow simonmar at microsoft.com
Thu Jan 5 05:56:50 EST 2006


John Goerzen wrote:
> I think you have that backwards, but I'm unsure.  According to the FFI
> spec, section 3.3:
> 
>   "Optionally, an import declaration can specify, after the calling
>   convention, the safety level that should be used when invoking an
>   external entity. A safe call is less efficient, but guarantees to
>   leave the Haskell system in a state that allows callbacks from the
>   external code. In contrast, an unsafe call, while carrying less
>   overhead, must not trigger a callback into the Haskell system."
> 
> There is no reason for any of these calls to trigger a callback into
> Haskell, so they can all be imported unsafe for greater efficiency.
> 
> But it doesn't directly address threads, so I don't know what to make of
> that.  Do you have a reference?

In GHC, other threads cannot run while an unsafe foreign call is in
progress.  Our documentation is slightly lacking here, but this paper
describes it all:

   http://www.haskell.org/~simonmar/papers/conc-ffi.pdf

If you have foreign calls which might block or just take a long time, it
is good practice not to mark them unsafe.

Cheers,
	Simon



More information about the Haskell mailing list