Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <xavier.leroy@inria.fr>
To: Harry Chomsky <harry@chomsky.net>
Cc: Caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] enter_blocking_section / leave_blocking_section question
Date: Mon, 27 May 2002 16:31:28 +0200	[thread overview]
Message-ID: <20020527163128.B24499@pauillac.inria.fr> (raw)
In-Reply-To: <00e401c2020a$78463230$0200a8c0@harry>; from harry@chomsky.net on Wed, May 22, 2002 at 08:32:30PM -0700

> I'm starting to use threads with my OCaml-Win32 library, and I'd like to
> annotate it with appropriate calls to enter_blocking_section and
> leave_blocking_section.  Clearly, if I make a call to a Win32 API function
> that may take some time, I'll surround the call with enter_blocking_section
> / leave_blocking_section.  But what if that function may make a callback to
> my own code, which may in turn pass control back to OCaml?

I believe the solution you outline in your message is correct:

> LRESULT window_proc(...)
> {
>     leave_blocking_section();
>     callback(...); // call OCaml window proc
>     enter_blocking_section();
> }
> 
> Obviously I'll need to guarantee that whenever window_proc is called, it
> happens during a blocking section.

Agreed.  Moreover, you should make sure that window_proc is always
called from a thread that was created by Caml, and not some other
thread created by the system.  (I don't believe Windows message
handling creates such extra threads, though.)

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


      reply	other threads:[~2002-05-27 14:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-23  3:32 Harry Chomsky
2002-05-27 14:31 ` Xavier Leroy [this message]

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=20020527163128.B24499@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=harry@chomsky.net \
    /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