From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA24969; Mon, 27 May 2002 16:31:31 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA25011 for ; Mon, 27 May 2002 16:31:31 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g4REVSD28439; Mon, 27 May 2002 16:31:28 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA25047; Mon, 27 May 2002 16:31:28 +0200 (MET DST) Date: Mon, 27 May 2002 16:31:28 +0200 From: Xavier Leroy To: Harry Chomsky Cc: Caml-list Subject: Re: [Caml-list] enter_blocking_section / leave_blocking_section question Message-ID: <20020527163128.B24499@pauillac.inria.fr> References: <00e401c2020a$78463230$0200a8c0@harry> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <00e401c2020a$78463230$0200a8c0@harry>; from harry@chomsky.net on Wed, May 22, 2002 at 08:32:30PM -0700 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > 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