This class acts like a combined ref-count as well as a spin-lock (only when adding the first or removing the last reference), allowing to run a specific action atomically when adding the first or dropping the last reference.