You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the PrefixingBufferWriter in a context that may throw after bytes have been written to it.
It does not implement IDisposable, yet it seems that it may have a sequence memory pool allocation if writing has started. I can see that the sequence is reset/memory returned when Commit() is called. But, how do I ensure that the allocated sequence is correctly returned to the pool in the case where Commit() is not called on a writer?
The text was updated successfully, but these errors were encountered:
I'm not sure. If an exception were thrown, I would tend to distrust anything in a writing chain. If the exception were thrown by Commit() itself for example, there's no telling how much data was written to the underlying writer. What kind of recovery did you have in mind after a writing exception is thrown?
using var sequnce = SequencePool.Get();
var writer = new PrefixingBufferWriter(sequence, 4);
// Do something that writes - it may throw
writer.Commit();
sequence.Flush();
...
In this case I do not plan to rely on any of the bytes written to the writer in case that the intermediate writing logic throws, but I would like to have guarantees that the writer does not leak. Does this make sense?
Hi,
I am using the
PrefixingBufferWriter
in a context that may throw after bytes have been written to it.It does not implement
IDisposable
, yet it seems that it may have a sequence memory pool allocation if writing has started. I can see that the sequence is reset/memory returned whenCommit()
is called. But, how do I ensure that the allocated sequence is correctly returned to the pool in the case whereCommit()
is not called on a writer?The text was updated successfully, but these errors were encountered: