chriskohlhoff / asio-tr2

C++ TR2 proposal based on Asio
17 stars 5 forks source link

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

Open chriskohlhoff opened 9 years ago

chriskohlhoff commented 9 years ago

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.

ja11sop commented 9 years ago

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 commented 9 years ago

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.