added atomic writes to circularBuffer