writer is only accessed from the internal thread