From: Eric Wong Date: 2018-05-18T18:10:35+00:00 Subject: [ruby-core:87175] Re: [Ruby trunk Feature#14767] [PATCH] gc.c: use monotonic counters for objspace_malloc_increase nobu@ruby-lang.org wrote: > ```C > size_t add = ATOMIC_SIZE_EXCHANGE(mc->add, 0); > size_t sub = ATOMIC_SIZE_EXCHANGE(mc->sub, 0); > ``` > > Is this combination of two atomic operations atomic? No, though I don't think it matters too much. If we really care about atomicity, we can use pointers to monoctr and swap those, instead. struct monoctr *active; struct monoctr a; struct monoctr b; ATOMIC_PTR_EXCHANGE will keep ->active pointing to &a or &b But I think I'll redo the approach to this patch entirely next week... Unsubscribe: