I'm wondering what the threading issues may be with this - what if someone resets the before during another thread reading it? At a minimum it feels like pos and buffer should be reset atomically.