Details
Description
As is, we stash the value for bytes written and then call clearBytesWritten, but if the value changes between those two calls due to a write in another thread, we'll lose some bytes. We should modify it to do this operation atomically.