|
Boost Users : |
Subject: Re: [Boost-users] circular buffer in a multithreaded program
From: Lee Clagett (forum_at_[hidden])
Date: 2014-04-24 18:21:26
On Thu, Apr 24, 2014 at 8:24 AM, Sebastian Gesemann <s.gesemann_at_[hidden]>wrote:
> On Thu, Apr 24, 2014 at 1:59 PM, Lee Clagett <forum_at_[hidden]> wrote:
> >
> >>
> >> I also programmed in Java. From what I can tell, there is little
> >> difference between Java and C++ in this regard. The terminology is
> >> just different. What you call "monitor", "volatile" and "happens
> >> before" in Java is called "mutex", "amotic" and "sequenced before". On
> >> top of that C++11 allows you to use "weaker synchronization". But
> >> that's something I choose to ignore because it's just too easy to get
> >> it wrong and not worth the performance gain in my opinion.
> >
> > Volatile in C/C++ is not sequenced like atomics in Java. In many cases
> the
> > observed behavior on x86 platforms will be similar, but this is by
> chance.
> > C++11 and boost have std/boost::atomic, which will match the behavior of
> > Java atomics. C++11 and boost also have a std/boost::mutex
> implementation.
>
> Not sure whether this was meant as correction or you simply wanted to
> add your comment. Anyhow, I did not say anything about C++'s volatile.
> I tried to convey that the cases in which you would use volatile in
> Java are typically cases in which you would use atomics in C++.
>
> > Lee
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
Sorry I inverted your original sentence when I read it.
Lee
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net