From: "Harry Chomsky" <harry@chomsky.net>
To: "Caml-list" <caml-list@inria.fr>
Subject: [Caml-list] enter_blocking_section / leave_blocking_section question
Date: Wed, 22 May 2002 20:32:30 -0700 [thread overview]
Message-ID: <00e401c2020a$78463230$0200a8c0@harry> (raw)
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?
For instance, my OCaml code calls send_message, implemented as C code that
calls the Win32 SendMessage function. If I'm sending a message to a system
window, SendMessage just returns. But if I'm sending a message to an
OCaml-owned window, my C window procedure will be called, and that in turn
will call an OCaml window procedure.
I'm inclined to do something like this:
CAMLprim value send_message(...)
{
enter_blocking_section();
SendMessage(...);
leave_blocking_section();
}
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. Is it safe then for window_proc to
temporarily "suspend" the blocking section? The enter_ and leave_ calls
will always occur in the proper alternation, but the stack will be in a
different state when leave_ is called than when enter_ was called. I just
want to make sure that this still constitutes safe and proper use of the
blocking system.
-------------------
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
next reply other threads:[~2002-05-23 3:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-23 3:32 Harry Chomsky [this message]
2002-05-27 14:31 ` Xavier Leroy
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='00e401c2020a$78463230$0200a8c0@harry' \
--to=harry@chomsky.net \
--cc=caml-list@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).