Boost logo

Boost Users :

Subject: Re: [Boost-users] circular buffer in a multithreaded program
From: Sebastian Gesemann (s.gesemann_at_[hidden])
Date: 2014-04-24 08:24:49


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