Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] C callbacks and threading...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: [Caml-list] C callbacks and threading...
> The manual says a caml function can be registered and then used from
> the C runtime. Is this still true if called from a thread not
> created from within Caml ie. via the Thread module? I have vague
> recollections of caml's thread system involving some bookkeeping
> which probably rules this usage out.

It should work if:
- the Caml code doesn't use threads itself;
- you call it via callback_exn rather than callback (to make sure you
  always get control back from the Caml code);
- you protect the call to callback_exn by a mutex, to make sure that
  no two threads can call into Caml simultaneously.

In all other cases, and especially if the Caml code is multithreaded,
you would probably break something in the Caml runtime system.

- Xavier Leroy
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr