[Haskell-cafe] Re: FFI and callbacks

Lemmih lemmih at gmail.com
Thu Jul 21 08:38:11 EDT 2005


On 7/21/05, John Goerzen <jgoerzen at complete.org> wrote:
> On Thu, Jul 21, 2005 at 11:07:15AM +0400, Bulat Ziganshin wrote:
> > Hello Simon,
> >
> > Thursday, July 21, 2005, 1:16:10 AM, you wrote:
> >
> > SM> from a single thread.
> >
> > you can either:
> > 1) made all calls from single thread
> > 2) put all calls in "withMVar lock", where `lock` is a global MVar
> 
> OK, that makes sense.
> 
> > JG> 1. It seems that there is no function that says "block the current
> > JG> thread until the thread given by ThreadId dies"
> >
> > GHC concurrency stuff is very basic and low-level. there is several
> > libs which adds some more high-level abilities, including MissingH (see
> > Child.hs) and some functions in http://www-i2.informatik.rwth-aachen.de/~stolz/Haskell/CA.hs
> 
> Err, got a bit of egg on my face for that one.  Would have hoped I'd
> have remembered what's in the library I maintain ;-)
> 
> But actually, looking at it now, it's not a plain ThreadId that it waits
> for, but rather a Child, which is:
> 
> data Child a = Child ThreadId (MVar a)
> 
> Great if you use the Child.hs (which, for the record, is one of Peter
> Simons' works), but if somebody isn't using it, it may be nice to have
> another option.  I'll look into Simon's recipe and see if I  can
> understand it ;-)
> 
> FWIW, I think Python has some really great threading primitives.  From a
> brief look at what's in Haskell, I think they are all implementable in
> terms of the low-level features Haskell has (I'll trust you all on the
> waiting for a thread thing).  I may write something up along those
> lines, stick it in MissingH and offer it up for fptools if anyone is
> interested.
> 
> Also, I think it's annoying that ThreadId is not showable.  This could
> be very useful for debugging.

Prelude Control.Concurrent> :i ThreadId
data ThreadId = ThreadId GHC.Prim.ThreadId#
        -- Imported from GHC.Conc
instance Eq ThreadId    -- Imported from Control.Concurrent
instance Ord ThreadId   -- Imported from Control.Concurrent
instance Show ThreadId  -- Imported from Control.Concurrent

-- 
Friendly,
  Lemmih


More information about the Haskell-Cafe mailing list