octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Switch to std::atomic?


From: John W. Eaton
Subject: Re: Switch to std::atomic?
Date: Thu, 26 Sep 2019 17:43:11 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

On 9/26/19 5:18 PM, Rik wrote:

Was there a particular reason to make oct-atomic.c a 'C' language file
rather than a C++ file?  If possible, it would seem better to make this C++
and possible also add an 'inline' declaration so that we don't get function
call overhead.

To try to inline the calls to the atomic_fetch_add and atomic_fetch_sub, we would need to include stdatomic.h in dim_vector.h. I didn't think that was a good idea as it could conflict with other C++ header files.

When I tried to include stdatomic.h in oct-refcount.h and use those functions to provide direct replacements for the old OCTAVE_ATOMIC_* macros, I ran into errors. Testing now, I get errors when using g++ to compile a simple C++ file that has only

  #include <stdatomic.h>

in it. So it seems best to me to just use it from C and provide wrappers that can be used in C++.

jwe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]