caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* atomicity guarantees for threaded code
@ 2004-10-29 16:39 Ker Lutyn
  2004-10-29 21:50 ` [Caml-list] " David Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Ker Lutyn @ 2004-10-29 16:39 UTC (permalink / raw)
  To: caml-list

Are there any guarantees for atomicity in threaded OCaml code? Or must I always
use a mutex? For example:

module StringMap = Map.Make (String)

let mapref = ref StringMap.empty

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?



		
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail 


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-10-30  2:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-29 16:39 atomicity guarantees for threaded code Ker Lutyn
2004-10-29 21:50 ` [Caml-list] " David Brown
2004-10-29 23:54   ` skaller
2004-10-30  0:32     ` David Brown
2004-10-30  1:07       ` skaller
2004-10-30  2:07         ` David Brown
2004-10-30  2:36           ` skaller

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