Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2004-10-29 (16:39)
From: Ker Lutyn <ker527mail@y...>
Subject: atomicity guarantees for threaded code
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.