asio-tr2 icon indicating copy to clipboard operation
asio-tr2 copied to clipboard

In async_read, lifetime requirements for the dynamic buffer aren't quite right

Open chriskohlhoff opened this issue 10 years ago • 2 comments

The program must ensure both the AsyncReadStream object stream and the memory associated with the dynamic buffer sequence b are valid until the handler for the asynchronous operation is invoked.

Memory validity is only required across the individual async_read_some operations.

chriskohlhoff avatar Feb 26 '15 10:02 chriskohlhoff

I've been thinking about this and I have a feeling that there is a general concept that needs to be satisfied by buffers that can be written to (as a result of a read operation). Now that we have renamed DynamicBufferSequence to DynamicBuffer and this is a buffer, then I feel that the concept of reading and writing to a buffer is different to the concept of whether an operation on a buffer requires access to a mutable sequence of bytes or a constant sequence of bytes.

With that in mind I wonder if the specification of memory validity for the duration of an operation can be specified in terms of the required mutability or not of the bytes that are provided through either a Buffer or a DynamicBuffer.

ja11sop avatar Feb 26 '15 10:02 ja11sop

In thinking about this more I think it might be sufficient that the buffer sequences requirements imply the required requirements for the buffer they are taken from.

ja11sop avatar Feb 26 '15 10:02 ja11sop