Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Automatic wrapper generator
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: thornber@r...
Subject: Re: [Caml-list] Functional critical section
On Tue, May 18, 2004 at 01:39:44PM -0700, Evan Martin wrote:
> Sure, that's the sort of thing that anonymous functions are great for.
> 
> let criticial f =
>   Mutex.lock someMutex;
>   let tmp = f () in
>   Mutex.unlock someMutex;
>   tmp

If f throws an exception the mutex will not get unlocked, which is
probably not what you wanted.

- Joe

-------------------
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