Closed bollhals closed 4 years ago
6.0 release notes mention this. We can make this even clearer. So do the .NET client guide docs but not for basic.return
s.
I'm not sure what you are suggesting making IDisposable
but we trust your judgement and would consider your contributions :)
The above also includes contributions to the .NET client guide, of course. Release notes are only editable by our team, so it'd be on me to update them as we see fit.
Yes you're right, the BasicReturn should be safe / like the BasicDeliver, now that I think about it.
The thing is, how should users of e.g. BasicGet return the rented payload? They'd have to do this:
if (MemoryMarshal.TryGetArray(memory, out ArraySegment<byte> segment))
{
ArrayPool<byte>.Shared.Return(segment.Array);
}
which is not really userfriendly. Hence to smooth this a bit, maybe implementing IDisposable on the BasicGetResult, that would do that for the user, if he disposes the BasicGetResult.
@bollhals yup, then making BasicGetResult
disposable makes a lot of sense.
Excellent, then I'll plan this in my next PR.
For "BasicDeliver" the rules got changed so that after you return from "BasicDeliver", the body reference shall not be used anymore from the outside. As far as I can tell this is due to the buffer being returned.
For BasicGet & BasicReturn the same actually applies as well. But instead of the library code doing it, it's the users responsiblity as once we returned the class, the library lost all control over it. Are users aware of this? Would we need to make it more obvious (E.g. by implementing IDisposable on it?)