caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Brown <caml-list@davidb.org>
To: Ker Lutyn <ker527mail@yahoo.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] atomicity guarantees for threaded code
Date: Fri, 29 Oct 2004 14:50:27 -0700	[thread overview]
Message-ID: <20041029215027.GA9504@old.davidb.org> (raw)
In-Reply-To: <20041029163907.36287.qmail@web40611.mail.yahoo.com>

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


  reply	other threads:[~2004-10-29 21:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-29 16:39 Ker Lutyn
2004-10-29 21:50 ` David Brown [this message]
2004-10-29 23:54   ` [Caml-list] " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041029215027.GA9504@old.davidb.org \
    --to=caml-list@davidb.org \
    --cc=caml-list@inria.fr \
    --cc=ker527mail@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).