caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: ygrek <ygrekheretix@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Callbacks from C to OCaml
Date: Sat, 11 Jul 2009 10:54:03 +0300	[thread overview]
Message-ID: <20090711105403.8bb1e112.ygrekheretix@gmail.com> (raw)
In-Reply-To: <000d01ca014f$e119a980$a34cfc80$@com>

[-- Attachment #1: Type: text/plain, Size: 1135 bytes --]

On Fri, 10 Jul 2009 12:16:17 +0100
"David Allsopp" <dra-news@metastack.com> wrote:

> Now, at any time, the SCM may invoke the ServiceCtrlHandler function
> registered with it. This also needs to callback to an OCaml function to work
> out what to do (the closure was registered in the initial call).
> 
> What happens at this point with regard to OCaml's global lock and being in
> the correct threading context? I must confess that I don't fully understand
> how the callback works at all in the single-threaded context - presumably
> when SCM calls the function, it simply executes code in its own thread
> context (so it can presumably introduce a form of multi-threading to a
> program which isn't expecting it?).

Yes, SCM creates new thread for the callback.
And this thread is not registered with OCaml runtime, and so
you can't do any allocation on it. I used windows services in the same setup and  
just set a boolean flag when SCM signalled service to stop, while periodically checking
this flag in ocaml thread..

See also http://caml.inria.fr/mantis/view.php?id=4702

Hope it helps.

-- 
 ygrek

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2009-07-11  7:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-10 11:16 David Allsopp
2009-07-11  7:54 ` ygrek [this message]
2009-07-11 11:39   ` [Caml-list] " David Allsopp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090711105403.8bb1e112.ygrekheretix@gmail.com \
    --to=ygrekheretix@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).