iou icon indicating copy to clipboard operation
iou copied to clipboard

Clearly document lifetime requirements on SQE arguments

Open withoutboats opened this issue 5 years ago • 1 comments

Any argument to an SQE prep method which is a reference (e.g. buffers, the mutable references in prep_accept) must outlive the completion of the IO event that is being prepared. There's no way to directly express this lifetime, as the completion of the IO is dynamic and unpredictable. This is the core reason these prep APIs are marked unsafe.

Users of iou are responsible for guaranteeing that these values will not be invalidated until after the completion occurs. We should provide clear, precise, and comprehensible documentation about the safety requirements of these methods.

withoutboats avatar Dec 22 '19 23:12 withoutboats

Would it be better to use a raw pointer (*mut [u8]) instead of a reference (&'unknown mut [u8])?

Nugine avatar Jan 22 '21 14:01 Nugine