diff libinterp/parse-tree/jit-typeinfo.cc @ 27447:396996f1dad0

use std::atomic to implement refcount class * oct-atomic.h, oct-atomic.c: New files. * liboctave/util/module.mk: Update. * dim-vector.h (dim_vector::increment_count, dim_vector::decrement_count): New functions. Use them instead of OCTAVE_ATOMIC_INCREMENT and OCTAVE_ATOMIC_DECREMENT macros. * Array.h (Array<T>::jit_ref_count): Return int, not pointer. Change all uses. * jit-typeinfo.h, jit-typeinfo.cc (jit_array::m_ref_count): Store integer, not pointer. Change all uses. * oct-refcount.h (OCTAVE_ATOMIC_INCREMENT, OCTAVE_ATOMIC_DECREMENT, OCTAVE_ATOMIC_POST_INCREMENT, OCTAVE_ATOMIC_POST_DECREMENT): Delete macros. (refcount::m_count): Now std::atomic<T> instead of T. (refcount::operator++, refcount::operator--): Define using std::atomic operators instead of increment macros. (refcount::get): Delete. (class refcount): Explicitly delete assignment operator and copy constructor. Explicitly use default destructor. Eliminate all uses of assignment as directly setting the reference count value apart from initialization should not be needed.
author John W. Eaton <jwe@octave.org>
date Wed, 25 Sep 2019 17:57:08 -0400
parents db687716fed6
children b442ec6dda5c
line wrap: on
line diff
--- a/libinterp/parse-tree/jit-typeinfo.cc	Thu Sep 26 11:32:52 2019 -0400
+++ b/libinterp/parse-tree/jit-typeinfo.cc	Wed Sep 25 17:57:08 2019 -0400
@@ -298,7 +298,7 @@
     bool done = false;
 
     // optimize for the simple case (no resizing and no errors)
-    if (*array->jit_ref_count () == 1
+    if (array->jit_ref_count () == 1
         && index->all_elements_are_ints ())
       {
         // this code is similar to idx_vector::fill, but we avoid allocating an