diff options
Diffstat (limited to 'intern/cycles/util/util_stats.h')
-rw-r--r-- | intern/cycles/util/util_stats.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/intern/cycles/util/util_stats.h b/intern/cycles/util/util_stats.h index 8758b823084..ce27067dc5e 100644 --- a/intern/cycles/util/util_stats.h +++ b/intern/cycles/util/util_stats.h @@ -11,12 +11,14 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License + * limitations under the License. */ #ifndef __UTIL_STATS_H__ #define __UTIL_STATS_H__ +#include "util_atomic.h" + CCL_NAMESPACE_BEGIN class Stats { @@ -24,14 +26,13 @@ public: Stats() : mem_used(0), mem_peak(0) {} void mem_alloc(size_t size) { - mem_used += size; - if(mem_used > mem_peak) - mem_peak = mem_used; + atomic_add_z(&mem_used, size); + atomic_update_max_z(&mem_peak, mem_used); } void mem_free(size_t size) { assert(mem_used >= size); - mem_used -= size; + atomic_sub_z(&mem_used, size); } size_t mem_used; |