From: Duncan C. <dun...@wo...> - 2007-05-06 20:09:14
|
On Sat, 2007-05-05 at 12:56 -0400, Peter Gavin wrote: > Hi everyone, > > GnomeVFS has a whole lot of asynchronous operations that take a > function pointer to a callback as an argument. It looks like the > library has a job queue that is processed in a separate thread. Is > marking the wrapper imports for the callbacks with safe sufficient to > keep the Haskell runtime from breaking? I guess, basically what I > mean is, is it ok to pass a Haskell closure to C, then for C to call > the closure in a thread that is completely independent of Haskell? Yes, that is fine. The rule is, you're allowed to mark a foreign call as unsafe, only if you know that the code you're calling will never call back to Haskell. It's only worth using the unsafe call with it's slightly lower calling overhead it if the foreign call is very short running and is potentially called often. Duncan |