I think the safer route is what recent commits like df3978c2340 did, convert the field to pg_atomic and use pg_atomic_read_membarrier_u32() and pg_atomic_write_membarrier_u32().
Actually, v1 conflicted with that commit, rebasing.
The reason I didn't want to do that is that I wanted a uniform way to handle
all types.
v1.1 pg_atomic_{write,read}_membarrier_uint{32,64} and keeps the
lock for 8- and 16-bits.
Can we use pg_atomic_flag for bool, or will that have different representations?