Version française
Home     About     Download     Resources     Contact us    
Browse thread
atomicity guarantees for threaded code
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David Brown <caml-list@d...>
Subject: Re: [Caml-list] atomicity guarantees for threaded code
On Fri, Oct 29, 2004 at 09:39:07AM -0700, Ker Lutyn wrote:

> thread 1:
> 
>     mapref := StringMap.add key value !mapref
> 
> thread 2 through thread N:
> 
>     let value = StringMap.find key !mapref
> 
> Assume only thread 1 can update the reference. Is this code safe?

As long as the reference write is atomic, which it is going to be, I would
suspect this is safe.  It probably would even be safe if multiple threads
updated the reference, but you might just drop entries.

Dave