Make buffer advancing atomic